1  /-
  2  Copyright (c) 2017 Johannes Hölzl. All rights reserved.
  3  Released under Apache 2.0 license as described in the file LICENSE.
  4  Authors: Johannes Hölzl, Jeremy Avigad
  5  -/
  6  import order.galois_connection order.zorn
src         └─────────────────────┘ └────────┘
  7  import data.set.finite
src         └─────────────┘
  8  
  9  /-! # Theory of filters on sets
 10  
 11  ## Main definitions
 12  
 13  * `filter` : filter on a set;
 14  * `at_top`, `at_bot`, `cofinite`, `principal` : specific filters;
 15  * `map`, `comap`, `join` : operations on filters;
 16  * `filter_upwards [h₁, ..., hₙ]` : takes a list of proofs `hᵢ : sᵢ ∈ f`, and replaces a goal `s ∈ f`
 17    with `∀ x, x ∈ s₁ → ... → x ∈ sₙ → x ∈ s`;
 18  * `eventually` : `f.eventually p` means `{x | p x} ∈ f`;
 19  * `frequently` : `f.frequently p` means `{x | ¬p x} ∉ f`.
 20  
 21  ## Notations
 22  
 23  * `∀ᶠ x in f, p x` : `f.eventually p`;
 24  * `∃ᶠ x in f, p x` : `f.frequently p`.
 25  -/
 26  open lattice set
 27  
 28  universes u v w x y
 29  
 30  open_locale classical
 31  
 32  namespace lattice
 33  variables {α : Type u} {ι : Sort v}
 34  
 35  def complete_lattice.copy (c : complete_lattice α)
id                                  └──────────────┘ 
src                                 └──────────────┘
typ                                 └──────────────┘ 
doc                                 └──────────────┘
 36    (le : α → α → Prop) (eq_le : le = @complete_lattice.le α c)
id                                └┘   └─────────────────┘  
src                                      └─────────────────┘
typ                               └┘   └─────────────────┘  
 37    (top : α) (eq_top : top = @complete_lattice.top α c)
id                        └─┘   └──────────────────┘  
src                              └──────────────────┘
typ                       └─┘   └──────────────────┘  
 38    (bot : α) (eq_bot : bot = @complete_lattice.bot α c)
id                        └─┘   └──────────────────┘  
src                              └──────────────────┘
typ                       └─┘   └──────────────────┘  
 39    (sup : α → α → α) (eq_sup : sup = @complete_lattice.sup α c)
id                              └─┘   └──────────────────┘  
src                                      └──────────────────┘
typ                             └─┘   └──────────────────┘  
 40    (inf : α → α → α) (eq_inf : inf = @complete_lattice.inf α c)
id                              └─┘   └──────────────────┘  
src                                      └──────────────────┘
typ                             └─┘   └──────────────────┘  
 41    (Sup : set α → α) (eq_Sup : Sup = @complete_lattice.Sup α c)
id            └─┘                └─┘   └──────────────────┘  
src           └─┘                        └──────────────────┘
typ           └─┘                └─┘   └──────────────────┘  
 42    (Inf : set α → α) (eq_Inf : Inf = @complete_lattice.Inf α c) :
id            └─┘                └─┘   └──────────────────┘  
src           └─┘                        └──────────────────┘
typ           └─┘                └─┘   └──────────────────┘  
 43    complete_lattice α :=
id     └──────────────┘ 
src    └──────────────┘
typ    └──────────────┘ 
doc    └──────────────┘
 44  begin
st   └─────
 45    refine { le := le, top := top, bot := bot, sup := sup, inf := inf, Sup := Sup, Inf := Inf, ..};
id                   └┘         └─┘         └─┘         └─┘         └─┘         └─┘         └─┘
src    └─────┘└─────┘  └───────┘   └───────┘   └───────┘   └───────┘   └───────┘   └───────┘   └───┘
typ    └─────┘└─────┘└┘└───────┘└─┘└───────┘└─┘└───────┘└─┘└───────┘└─┘└───────┘└─┘└───────┘└─┘└───┘
doc    └─────┘ └─────┘  └───────┘   └───────┘   └───────┘   └───────┘   └───────┘   └───────┘   └───┘
txt    └─────┘ └─────┘  └───────┘   └───────┘   └───────┘   └───────┘   └───────┘   └───────┘   └───┘
par    └─────┘ └─────┘  └───────┘   └───────┘   └───────┘   └───────┘   └───────┘   └───────┘   └───┘
pid           └─────┘  └───────┘   └───────┘   └───────┘   └───────┘   └───────┘   └───────┘   └───┘
st   ──────────────────────────────────────────────────────────────────────────────────────────────────
 46      subst_vars,
src      └────────┘
typ      └────────┘
doc      └────────┘
txt      └────────┘
par      └────────┘
st   ─────────────┘└─
 47    exact @complete_lattice.le_refl α c,
id            └──────────────────────┘  
src    └────┘ └──────────────────────┘ 
typ    └────┘ └──────────────────────┘
doc    └────┘                          
txt    └────┘                          
par    └────┘                          
pid                                   
st   ────────────────────────────────────┘└─
 48    exact @complete_lattice.le_trans α c,
id            └───────────────────────┘  
src    └────┘ └───────────────────────┘ 
typ    └────┘ └───────────────────────┘
doc    └────┘                           
txt    └────┘                           
par    └────┘                           
pid                                    
st   ─────────────────────────────────────┘└─
 49    exact @complete_lattice.le_antisymm α c,
id            └──────────────────────────┘  
src    └────┘ └──────────────────────────┘ 
typ    └────┘ └──────────────────────────┘
doc    └────┘                              
txt    └────┘                              
par    └────┘                              
pid                                       
st   ────────────────────────────────────────┘└─
 50    exact @complete_lattice.le_sup_left α c,
id            └──────────────────────────┘  
src    └────┘ └──────────────────────────┘ 
typ    └────┘ └──────────────────────────┘
doc    └────┘                              
txt    └────┘                              
par    └────┘                              
pid                                       
st   ────────────────────────────────────────┘└─
 51    exact @complete_lattice.le_sup_right α c,
id            └───────────────────────────┘  
src    └────┘ └───────────────────────────┘ 
typ    └────┘ └───────────────────────────┘
doc    └────┘                               
txt    └────┘                               
par    └────┘                               
pid                                        
st   ─────────────────────────────────────────┘└─
 52    exact @complete_lattice.sup_le α c,
id            └─────────────────────┘  
src    └────┘ └─────────────────────┘ 
typ    └────┘ └─────────────────────┘
doc    └────┘                         
txt    └────┘                         
par    └────┘                         
pid                                  
st   ───────────────────────────────────┘└─
 53    exact @complete_lattice.inf_le_left α c,
id            └──────────────────────────┘  
src    └────┘ └──────────────────────────┘ 
typ    └────┘ └──────────────────────────┘
doc    └────┘                              
txt    └────┘                              
par    └────┘                              
pid                                       
st   ────────────────────────────────────────┘└─
 54    exact @complete_lattice.inf_le_right α c,
id            └───────────────────────────┘  
src    └────┘ └───────────────────────────┘ 
typ    └────┘ └───────────────────────────┘
doc    └────┘                               
txt    └────┘                               
par    └────┘                               
pid                                        
st   ─────────────────────────────────────────┘└─
 55    exact @complete_lattice.le_inf α c,
id            └─────────────────────┘  
src    └────┘ └─────────────────────┘ 
typ    └────┘ └─────────────────────┘
doc    └────┘                         
txt    └────┘                         
par    └────┘                         
pid                                  
st   ───────────────────────────────────┘└─
 56    exact @complete_lattice.le_top α c,
id            └─────────────────────┘  
src    └────┘ └─────────────────────┘ 
typ    └────┘ └─────────────────────┘
doc    └────┘                         
txt    └────┘                         
par    └────┘                         
pid                                  
st   ───────────────────────────────────┘└─
 57    exact @complete_lattice.bot_le α c,
id            └─────────────────────┘  
src    └────┘ └─────────────────────┘ 
typ    └────┘ └─────────────────────┘
doc    └────┘                         
txt    └────┘                         
par    └────┘                         
pid                                  
st   ───────────────────────────────────┘└─
 58    exact @complete_lattice.le_Sup α c,
id            └─────────────────────┘  
src    └────┘ └─────────────────────┘ 
typ    └────┘ └─────────────────────┘
doc    └────┘                         
txt    └────┘                         
par    └────┘                         
pid                                  
st   ───────────────────────────────────┘└─
 59    exact @complete_lattice.Sup_le α c,
id            └─────────────────────┘  
src    └────┘ └─────────────────────┘ 
typ    └────┘ └─────────────────────┘
doc    └────┘                         
txt    └────┘                         
par    └────┘                         
pid                                  
st   ───────────────────────────────────┘└─
 60    exact @complete_lattice.Inf_le α c,
id            └─────────────────────┘  
src    └────┘ └─────────────────────┘ 
typ    └────┘ └─────────────────────┘
doc    └────┘                         
txt    └────┘                         
par    └────┘                         
pid                                  
st   ───────────────────────────────────┘└─
 61    exact @complete_lattice.le_Inf α c
id            └─────────────────────┘  
src    └────┘ └─────────────────────┘  
typ    └────┘ └─────────────────────┘
doc    └────┘                          
txt    └────┘                          
par    └────┘                          
pid                                   
st   ────────────────────────────────────┘
 62  end
st   └─┘
 63  
 64  end lattice
 65  
 66  open set lattice
 67  
 68  section order
 69  variables {α : Type u} (r : α → α → Prop)
 70  local infix ` ≼ ` : 50 := r
 71  
 72  lemma directed_on_Union {r} {ι : Sort v} {f : ι → set α} (hd : directed (⊆) f)
id                                                    └─┘         └──────┘    
src                                                    └─┘          └──────┘ 
typ                                                   └─┘         └──────┘    
doc                                                                 └──────┘
 73    (h : ∀x, directed_on r (f x)) : directed_on r (⋃x, f x) :=
id             └─────────┘         └─────────┘     
src             └─────────┘            └─────────┘     
typ            └─────────┘         └─────────┘     
doc             └─────────┘            └─────────┘     
 74  by simp only [directed_on, exists_prop, mem_Union, exists_imp_distrib]; exact
id                 └─────────┘  └─────────┘  └───────┘  └────────────────┘
src     └─────────┘└─────────┘└┘└─────────┘└┘└───────┘└┘└────────────────┘  └────┘
typ     └─────────┘└─────────┘└┘└─────────┘└┘└───────┘└┘└────────────────┘  └────┘
doc     └─────────┘└─────────┘└┘           └┘         └┘                    └────┘
txt     └─────────┘           └┘           └┘         └┘                    └────┘
par     └─────────┘           └┘           └┘         └┘                    └────┘
pid         └──┘└┘           └┘           └┘         └┘                         
st     └───────────────────────────────────────────────────────────────────────────
 75  assume a₁ b₁ fb₁ a₂ b₂ fb₂,
src        └────────────────────┘
typ        └────────────────────┘
doc        └────────────────────┘
txt        └────────────────────┘
par        └────────────────────┘
pid        └────────────────────┘
st   ────────────────────────────
 76  let ⟨z, zb₁, zb₂⟩ := hd b₁ b₂,
id          └─┘  └─┘     └┘
src       └┘   └┘   └───┘      └─
typ      └┘└─┘└┘└─┘└───┘└┘    └─
doc       └┘   └┘   └───┘      └─
txt       └┘   └┘   └───┘      └─
par       └┘   └┘   └───┘      └─
pid       └┘   └┘   └───┘      └─
st   ───────────────────────────────
 77      ⟨x, xf, xa₁, xa₂⟩ := h z a₁ (zb₁ fb₁) a₂ (zb₂ fb₂) in
id          └┘  └─┘  └─┘     
src  ───┘  └┘  └┘   └┘   └───┘           └┘         └───┘
typ  ───┘ └┘└┘└┘└─┘└┘└─┘└───┘          └┘         └───┘
doc  ───┘  └┘  └┘   └┘   └───┘           └┘         └───┘
txt  ───┘  └┘  └┘   └┘   └───┘           └┘         └───┘
par  ───┘  └┘  └┘   └┘   └───┘           └┘         └───┘
pid  ───┘  └┘  └┘   └┘   └───┘           └┘         └───┘
st   ──────────────────────────────────────────────────────────
 78  ⟨x, ⟨z, xf⟩, xa₁, xa₂⟩
src    └┘  └┘  └─┘   └┘   └─
typ    └┘  └┘  └─┘   └┘   └─
doc    └┘  └┘  └─┘   └┘   └─
txt    └┘  └┘  └─┘   └┘   └─
par    └┘  └┘  └─┘   └┘   └─
pid    └┘  └┘  └─┘   └┘   
st   ───────────────────────
 79  
src  
typ  
doc  
txt  
par  
pid  
st   
 80  end order
 81  
 82  theorem directed_of_chain {α β r} [is_refl β r] {f : α → β} {c : set α}
id                                      └─────┘                   └─┘ 
src                                     └─────┘                       └─┘
typ                                     └─────┘                   └─┘ 
 83    (h : zorn.chain (f ⁻¹'o r) c) :
id          └────────┘   └──┘   
src         └────────┘    └──┘
typ         └────────┘   └──┘   
doc         └────────┘    └──┘
 84    directed r (λx:{a:α // a ∈ c}, f (x.val)) :=
id     └──────┘                   └──┘
src    └──────┘                         └──┘
typ    └──────┘                   └──┘
doc    └──────┘
 85  assume ⟨a, ha⟩ ⟨b, hb⟩, classical.by_cases
id            └┘         └────────────────┘
src                          └────────────────┘
typ           └┘         └────────────────┘
 86    (assume : a = b, by simp only [this, exists_prop, and_self, subtype.exists];
id                                   └──┘  └─────────┘  └──────┘  └────────────┘
src                       └─────────┘    └┘└─────────┘└┘└──────┘└┘└────────────┘
typ                       └─────────┘└──┘└┘└─────────┘└┘└──────┘└┘└────────────┘
doc                        └─────────┘    └┘           └┘        └┘              
txt                        └─────────┘    └┘           └┘        └┘              
par                        └─────────┘    └┘           └┘        └┘              
pid                            └──┘└┘    └┘           └┘        └┘              
st                        └─────────────────────────────────────────────────────────
 87      exact ⟨b, hb, refl _⟩)
id                └┘  └──┘
src      └────┘  └┘  └┘└──┘└─┘
typ      └────┘ └┘└┘└┘└──┘└─┘
doc      └────┘  └┘  └┘    └─┘
txt      └────┘  └┘  └┘    └─┘
par      └────┘  └┘  └┘    └─┘
pid             └┘  └┘    └─┘
st   ────────────────────────┘
 88    (assume : a ≠ b, (h a ha b hb this).elim
id                                 └──┘ └──┘
src                                      └──┘
typ                                └──┘ └──┘
 89      (λ h : r (f a) (f b), ⟨⟨b, hb⟩, h, refl _⟩)
id                                      └──┘
src                                         └──┘
typ                                     └──┘
 90      (λ h : r (f b) (f a), ⟨⟨a, ha⟩, refl _, h⟩))
id                                    └──┘    
src                                      └──┘
typ                                   └──┘    
 91  
 92  structure filter (α : Type*) :=
id                         └───┘
typ                        └───┘
 93  (sets                   : set (set α))
id                             └─┘  └─┘ 
src                            └─┘  └─┘
typ                            └─┘  └─┘ 
 94  (univ_sets              : set.univ ∈ sets)
id                             └──────┘  └──┘
src                            └──────┘ 
typ                            └──────┘  └──┘
 95  (sets_of_superset {x y} : x ∈ sets → x ⊆ y → y ∈ sets)
id                             └──┘          └──┘
src                                               
typ                            └──┘          └──┘
 96  (inter_sets {x y}       : x ∈ sets → y ∈ sets → x ∩ y ∈ sets)
id                             └──┘     └──┘       └──┘
src                                                     
typ                            └──┘     └──┘       └──┘
 97  
 98  /-- If `F` is a filter on `α`, and `U` a subset of `α` then we can write `U ∈ F` as on paper. -/
 99  @[reducible]
doc    └───────┘
100  instance {α : Type*}: has_mem (set α) (filter α) := ⟨λ U F, U ∈ F.sets⟩
id                         └─────┘  └─┘    └────┘              └───┘
src                        └─────┘  └─┘     └────┘                   └───┘
typ                        └─────┘  └─┘    └────┘              └───┘
101  
102  namespace filter
103  variables {α : Type u} {f g : filter α} {s t : set α}
id                                 └────┘           └─┘
src                                └────┘           └─┘
typ                                └────┘           └─┘
104  
105  lemma filter_eq : ∀{f g : filter α}, f.sets = g.sets → f = g
id                            └────┘    └───┘  └───┘     
src                            └────┘      └───┘   └───┘     
typ                           └────┘    └───┘  └───┘     
st                  
106  | ⟨a, _, _, _⟩ ⟨._, _, _, _⟩ rfl := rfl
id                                └─┘    └─┘
src                               └─┘    └─┘
typ                               └─┘    └─┘
107  
108  lemma filter_eq_iff : f = g ↔ f.sets = g.sets :=
id                             └───┘  └───┘
src                               └───┘   └───┘
typ                            └───┘  └───┘
109  ⟨congr_arg _, filter_eq⟩
id    └───────┘    └───────┘
src   └───────┘    └───────┘
typ   └───────┘    └───────┘
110  
111  protected lemma ext_iff : f = g ↔ ∀ s, s ∈ f ↔ s ∈ g :=
id                                           
src                                               
typ                                          
112  by rw [filter_eq_iff, ext_iff]
id          └───────────┘  └─────┘
src     └──┘└───────────┘└┘└─────┘└─
typ     └──┘└───────────┘└┘└─────┘└─
doc     └──┘             └┘       └─
txt     └──┘             └┘       └─
par     └──┘             └┘       └─
pid       └┘             └┘       
st     └────────────────┘└───────┘
113  
src  
typ  
doc  
txt  
par  
pid  
st   
114  @[ext]
doc    └─┘
115  protected lemma ext : (∀ s, s ∈ f ↔ s ∈ g) → f = g :=
id                                          
src                                              
typ                                         
116  filter.ext_iff.2
id   └────────────┘
src  └────────────┘
typ  └────────────┘
117  
118  lemma univ_mem_sets : univ ∈ f :=
id                         └──┘  
src                        └──┘ 
typ                        └──┘  
119  f.univ_sets
id   └────────┘
src   └────────┘
typ  └────────┘
120  
121  lemma mem_sets_of_superset : ∀{x y : set α}, x ∈ f → x ⊆ y → y ∈ f :=
id                                        └─┘                
src                                       └─┘                     
typ                                       └─┘                
122  f.sets_of_superset
id   └───────────────┘
src   └───────────────┘
typ  └───────────────┘
123  
124  lemma inter_mem_sets : ∀{s t}, s ∈ f → t ∈ f → s ∩ t ∈ f :=
id                                              
src                                                    
typ                                             
125  f.inter_sets
id   └─────────┘
src   └─────────┘
typ  └─────────┘
126  
127  lemma univ_mem_sets' (h : ∀ a, a ∈ s) : s ∈ f :=
id                                         
src                                           
typ                                        
128  mem_sets_of_superset univ_mem_sets (assume x _, h x)
id   └──────────────────┘ └───────────┘             
src  └──────────────────┘ └───────────┘
typ  └──────────────────┘ └───────────┘             
129  
130  lemma mp_sets (hs : s ∈ f) (h : {x | x ∈ s → x ∈ t} ∈ f) : t ∈ f :=
id                                                   
src                                                          
typ                                                  
131  mem_sets_of_superset (inter_mem_sets hs h) $ assume x ⟨h₁, h₂⟩, h₂ h₁
id   └──────────────────┘  └────────────┘ └┘             └┘  └┘
src  └──────────────────┘  └────────────┘
typ  └──────────────────┘  └────────────┘ └┘             └┘  └┘
132  
133  lemma congr_sets (h : {x | x ∈ s ↔ x ∈ t} ∈ f) : s ∈ f ↔ t ∈ f :=
id                                               
src                                                      
typ                                              
134  ⟨λ hs, mp_sets hs (mem_sets_of_superset h (λ x, iff.mp)),
id      └┘  └─────┘ └┘  └──────────────────┘       └────┘
src         └─────┘     └──────────────────┘         └────┘
typ     └┘  └─────┘ └┘  └──────────────────┘       └────┘
135   λ hs, mp_sets hs (mem_sets_of_superset h (λ x, iff.mpr))⟩
id      └┘  └─────┘ └┘  └──────────────────┘       └─────┘
src         └─────┘     └──────────────────┘         └─────┘
typ     └┘  └─────┘ └┘  └──────────────────┘       └─────┘
136  
137  lemma Inter_mem_sets {β : Type v} {s : β → set α} {is : set β} (hf : finite is) :
id                                             └─┘         └─┘         └────┘ └┘
src                                             └─┘          └─┘          └────┘
typ                                            └─┘         └─┘         └────┘ └┘
doc                                                                       └────┘
138    (∀i∈is, s i ∈ f) → (⋂i∈is, s i) ∈ f :=
id        └┘           └┘     
src                                
typ       └┘           └┘     
doc                            
139  finite.induction_on hf
id   └─────────────────┘ └┘
src  └─────────────────┘
typ  └─────────────────┘ └┘
140    (assume hs, by simp only [univ_mem_sets, mem_empty_eq, Inter_neg, Inter_univ, not_false_iff])
id             └┘                └───────────┘  └──────────┘  └───────┘  └────────┘  └───────────┘
src                   └─────────┘└───────────┘└┘└──────────┘└┘└───────┘└┘└────────┘└┘└───────────┘
typ            └┘     └─────────┘└───────────┘└┘└──────────┘└┘└───────┘└┘└────────┘└┘└───────────┘
doc                   └─────────┘             └┘            └┘         └┘          └┘             
txt                   └─────────┘             └┘            └┘         └┘          └┘             
par                   └─────────┘             └┘            └┘         └┘          └┘             
pid                       └──┘└┘             └┘            └┘         └┘          └┘             
st                   └────────────────────────────────────────────────────────────────────────────┘
141    (assume i is _ hf hi hs,
id              └┘  └┘ └┘ └┘
typ             └┘  └┘ └┘ └┘
142      have h₁ : s i ∈ f, from hs i (by simp),
id                           └┘ 
src                                      └──┘
typ                          └┘      └──┘
doc                                       └──┘
txt                                       └──┘
par                                       └──┘
st                                       └───┘
143      have h₂ : (⋂x∈is, s x) ∈ f, from hi $ assume a ha, hs _ $ by simp only [ha, mem_insert_iff, or_true],
id                   └┘            └┘           └┘  └┘                   └┘  └────────────┘  └─────┘
src                                                                └─────────┘  └┘└────────────┘└┘└─────┘
typ                  └┘            └┘           └┘  └┘        └─────────┘└┘└┘└────────────┘└┘└─────┘
doc                                                                 └─────────┘  └┘              └┘       
txt                                                                   └─────────┘  └┘              └┘       
par                                                                   └─────────┘  └┘              └┘       
pid                                                                       └──┘└┘  └┘              └┘       
st                                                                   └──────────────────────────────────────┘
144      by simp [inter_mem_sets h₁ h₂])
id                └────────────┘ └┘ └┘
src         └────┘└────────────┘    
typ         └────┘└────────────┘└┘└┘
doc         └────┘                  
txt         └────┘                  
par         └────┘                  
pid                               
st         └──────────────────────────┘
145  
146  lemma Inter_mem_sets_of_fintype {β : Type v} {s : β → set α} [fintype β] (h : ∀i, s i ∈ f) :
id                                                        └─┘    └─────┘              
src                                                        └─┘     └─────┘                 
typ                                                       └─┘    └─────┘              
doc                                                                └─────┘
147    (⋂i, s i) ∈ f :=
id           
src            
typ          
doc      
148  by simpa using Inter_mem_sets finite_univ (λi hi, h i)
id                  └────────────┘ └─────────┘         
src     └──────────┘└────────────┘└─────────┘  └────┘  └─
typ     └──────────┘└────────────┘└─────────┘  └────┘ └─
doc     └──────────┘                           └────┘  └─
txt     └──────────┘                           └────┘  └─
par     └──────────┘                           └────┘  └─
pid          └────┘                           └────┘  
st     └────────────────────────────────────────────────────
149  
src  
typ  
doc  
txt  
par  
pid  
st   
150  lemma exists_sets_subset_iff : (∃t ∈ f, t ⊆ s) ↔ s ∈ f :=
id                                              
src                                                 
typ                                             
151  ⟨assume ⟨t, ht, ts⟩, mem_sets_of_superset ht ts, assume hs, ⟨s, hs, subset.refl _⟩⟩
id              └┘  └┘   └──────────────────┘               └┘     └┘  └─────────┘
src                       └──────────────────┘                           └─────────┘
typ             └┘  └┘   └──────────────────┘               └┘     └┘  └─────────┘
152  
153  lemma monotone_mem_sets {f : filter α} : monotone (λs, s ∈ f) :=
id                                └────┘     └──────┘       
src                               └────┘      └──────┘        
typ                               └────┘     └──────┘       
doc                                           └──────┘
154  assume s t hst h, mem_sets_of_superset h hst
id            └─┘   └──────────────────┘  └─┘
src                    └──────────────────┘
typ           └─┘   └──────────────────┘  └─┘
155  
156  end filter
157  
158  namespace tactic.interactive
159  open tactic interactive
160  
161  /-- `filter_upwards [h1, ⋯, hn]` replaces a goal of the form `s ∈ f`
162  and terms `h1 : t1 ∈ f, ⋯, hn : tn ∈ f` with `∀x, x ∈ t1 → ⋯ → x ∈ tn → x ∈ s`.
163  
164  `filter_upwards [h1, ⋯, hn] e` is a short form for `{ filter_upwards [h1, ⋯, hn], exact e }`.
165  -/
166  meta def filter_upwards
167    (s : parse types.pexpr_list)
id          └───┘ └──────────────┘
src         └───┘ └──────────────┘
typ         └───┘ └──────────────┘
doc         └───┘
168    (e' : parse $ optional types.texpr) : tactic unit :=
id           └───┘   └──────┘ └─────────┘    └────┘ └──┘
src          └───┘   └──────┘ └─────────┘    └────┘ └──┘
typ          └───┘   └──────┘ └─────────┘    └────┘ └──┘
doc          └───┘            └─────────┘           └──┘
169  do
170    s.reverse.mmap (λ e, eapplyc `filter.mp_sets >> eapply e),
id     └──────┘└───┘      └─────┘                └┘ └────┘ 
src     └──────┘└───┘       └─────┘                └┘ └────┘
typ    └──────┘└───┘      └─────┘                └┘ └────┘ 
doc                                                    └────┘
171    eapplyc `filter.univ_mem_sets',
id     └─────┘ 
src    └─────┘ 
typ    └─────┘ 
172    match e' with
id           └┘
typ          └┘
173    | some e := interactive.exact e
id       └──┘     └───────────────┘
src      └──┘      └───────────────┘
typ      └──┘     └───────────────┘
doc                └───────────────┘
174    | none := skip
id       └──┘    └──┘
src      └──┘    └──┘
typ      └──┘    └──┘
doc              └──┘
175    end
176  
177  end tactic.interactive
178  
179  namespace filter
180  variables {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x}
id             
typ            
181  
182  section principal
183  
184  /-- The principal filter of `s` is the collection of all supersets of `s`. -/
185  def principal (s : set α) : filter α :=
id                      └─┘     └────┘ 
src                     └─┘      └────┘
typ                     └─┘     └────┘ 
186  { sets             := {t | s ⊆ t},
id                              
src                              
typ                             
187    univ_sets        := subset_univ s,
id                         └─────────┘ 
src                        └─────────┘
typ                        └─────────┘ 
188    sets_of_superset := assume x y hx hy, subset.trans hx hy,
id                                  └┘ └┘  └──────────┘ └┘ └┘
src                                          └──────────┘
typ                                 └┘ └┘  └──────────┘ └┘ └┘
189    inter_sets       := assume x y, subset_inter }
id                                   └──────────┘
src                                    └──────────┘
typ                                  └──────────┘
190  
191  instance : inhabited (filter α) :=
id              └───────┘  └────┘ 
src             └───────┘  └────┘
typ             └───────┘  └────┘ 
192  ⟨principal ∅⟩
id    └───────┘ 
src   └───────┘ 
typ   └───────┘ 
doc   └───────┘
193  
194  @[simp] lemma mem_principal_sets {s t : set α} : s ∈ principal t ↔ t ⊆ s := iff.rfl
id                                           └─┘       └───────┘         └─────┘
src                                          └─┘         └───────┘            └─────┘
typ                                          └─┘       └───────┘         └─────┘
doc    └──┘                                               └───────┘
195  
196  lemma mem_principal_self (s : set α) : s ∈ principal s := subset.refl _
id                                 └─┘       └───────┘     └─────────┘
src                                └─┘         └───────┘      └─────────┘
typ                                └─┘       └───────┘     └─────────┘
doc                                             └───────┘
197  
198  end principal
199  
200  section join
201  
202  /-- The join of a filter of filters is defined by the relation `s ∈ join f ↔ {t | s ∈ t} ∈ f`. -/
203  def join (f : filter (filter α)) : filter α :=
id                 └────┘  └────┘      └────┘ 
src                └────┘  └────┘       └────┘
typ                └────┘  └────┘      └────┘ 
204  { sets             := {s | {t : filter α | s ∈ t} ∈ f},
id                                └────┘         
src                                └────┘           
typ                               └────┘         
205    univ_sets        := by simp only [univ_mem_sets, mem_set_of_eq]; exact univ_mem_sets,
id                                       └───────────┘  └───────────┘         └───────────┘
src                           └─────────┘└───────────┘└┘└───────────┘  └────┘└───────────┘
typ                           └─────────┘└───────────┘└┘└───────────┘  └────┘└───────────┘
doc                           └─────────┘             └┘               └────┘
txt                           └─────────┘             └┘               └────┘
par                           └─────────┘             └┘               └────┘
pid                               └──┘└┘             └┘                    
st                           └────────────────────────────────────────────────────────────┘
206    sets_of_superset := assume x y hx xy,
id                                  └┘ └┘
typ                                 └┘ └┘
207      mem_sets_of_superset hx $ assume f h, mem_sets_of_superset h xy,
id       └──────────────────┘ └┘             └──────────────────┘  └┘
src      └──────────────────┘                  └──────────────────┘
typ      └──────────────────┘ └┘             └──────────────────┘  └┘
208    inter_sets       := assume x y hx hy,
id                                  └┘ └┘
typ                                 └┘ └┘
209      mem_sets_of_superset (inter_mem_sets hx hy) $ assume f ⟨h₁, h₂⟩, inter_mem_sets h₁ h₂ }
id       └──────────────────┘  └────────────┘ └┘ └┘            └┘  └┘   └────────────┘
src      └──────────────────┘  └────────────┘                             └────────────┘
typ      └──────────────────┘  └────────────┘ └┘ └┘            └┘  └┘   └────────────┘
210  
211  @[simp] lemma mem_join_sets {s : set α} {f : filter (filter α)} :
id                                    └─┘        └────┘  └────┘ 
src                                   └─┘         └────┘  └────┘
typ                                   └─┘        └────┘  └────┘ 
doc    └──┘
212    s ∈ join f ↔ {t | s ∈ t} ∈ f := iff.rfl
id       └──┘               └─────┘
src       └──┘                    └─────┘
typ      └──┘               └─────┘
doc        └──┘
213  
214  end join
215  
216  section lattice
217  
218  instance : partial_order (filter α) :=
id              └───────────┘  └────┘ 
src             └───────────┘  └────┘
typ             └───────────┘  └────┘ 
219  { le            := λf g, ∀ ⦃U : set α⦄, U ∈ g → U ∈ f,
id                                └─┘           
src                                 └─┘              
typ                               └─┘           
220    le_antisymm   := assume a b h₁ h₂, filter_eq $ subset.antisymm h₂ h₁,
id                               └┘ └┘  └───────┘   └─────────────┘ └┘ └┘
src                                       └───────┘   └─────────────┘
typ                              └┘ └┘  └───────┘   └─────────────┘ └┘ └┘
221    le_refl       := assume a, subset.refl _,
id                               └─────────┘
src                               └─────────┘
typ                              └─────────┘
222    le_trans      := assume a b c h₁ h₂, subset.trans h₂ h₁ }
id                                └┘ └┘  └──────────┘ └┘ └┘
src                                         └──────────┘
typ                               └┘ └┘  └──────────┘ └┘ └┘
223  
224  theorem le_def {f g : filter α} : f ≤ g ↔ ∀ x ∈ g, x ∈ f := iff.rfl
id                         └────┘                      └─────┘
src                        └────┘                             └─────┘
typ                        └────┘                      └─────┘
225  
226  /-- `generate_sets g s`: `s` is in the filter closure of `g`. -/
227  inductive generate_sets (g : set (set α)) : set α → Prop
id                                └─┘  └─┘      └─┘
src                               └─┘  └─┘       └─┘
typ                               └─┘  └─┘      └─┘
228  | basic {s : set α}      : s ∈ g → generate_sets s
id                └─┘                               
src               └─┘             
typ               └─┘                               
229  | univ {}                : generate_sets univ
id                                            └──┘
src                                           └──┘
typ                                           └──┘
230  | superset {s t : set α} : generate_sets s → s ⊆ t → generate_sets t
id                     └─┘      └───────────┘                       
src                    └─┘                          
typ                    └─┘      └───────────┘                       
231  | inter {s t : set α}    : generate_sets s → generate_sets t → generate_sets (s ∩ t)
id                  └─┘         └───────────┘    └───────────┘                     
src                 └─┘                                                              
typ                 └─┘         └───────────┘    └───────────┘                     
232  
233  /-- `generate g` is the smallest filter containing the sets `g`. -/
234  def generate (g : set (set α)) : filter α :=
id                     └─┘  └─┘      └────┘ 
src                    └─┘  └─┘       └────┘
typ                    └─┘  └─┘      └────┘ 
235  { sets             := generate_sets g,
id                         └───────────┘ 
src                        └───────────┘
typ                        └───────────┘ 
doc                        └───────────┘
236    univ_sets        := generate_sets.univ,
id                         └────────────────┘
src                        └────────────────┘
typ                        └────────────────┘
237    sets_of_superset := assume x y, generate_sets.superset,
id                                   └────────────────────┘
src                                    └────────────────────┘
typ                                  └────────────────────┘
238    inter_sets       := assume s t, generate_sets.inter }
id                                   └─────────────────┘
src                                    └─────────────────┘
typ                                  └─────────────────┘
239  
240  lemma sets_iff_generate {s : set (set α)} {f : filter α} : f ≤ filter.generate s ↔ s ⊆ f.sets :=
id                                └─┘  └─┘         └────┘       └─────────────┘     └───┘
src                               └─┘  └─┘          └────┘         └─────────────┘        └───┘
typ                               └─┘  └─┘         └────┘       └─────────────┘     └───┘
doc                                                                 └─────────────┘
241  iff.intro
id   └───────┘
src  └───────┘
typ  └───────┘
242    (assume h u hu, h $ generate_sets.basic $ hu)
id               └┘     └─────────────────┘   └┘
src                        └─────────────────┘
typ              └┘     └─────────────────┘   └┘
243    (assume h u hu, hu.rec_on h univ_mem_sets
id               └┘  └┘└─────┘  └───────────┘
src                      └─────┘   └───────────┘
typ              └┘  └┘└─────┘  └───────────┘
244      (assume x y _ hxy hx, mem_sets_of_superset hx hxy)
id                  └─┘ └┘  └──────────────────┘ └┘ └─┘
src                            └──────────────────┘
typ                 └─┘ └┘  └──────────────────┘ └┘ └─┘
245      (assume x y _ _ hx hy, inter_mem_sets hx hy))
id                   └┘ └┘  └────────────┘ └┘ └┘
src                             └────────────┘
typ                  └┘ └┘  └────────────┘ └┘ └┘
246  
247  protected def mk_of_closure (s : set (set α)) (hs : (generate s).sets = s) : filter α :=
id                                    └─┘  └─┘           └──────┘  └──┘       └────┘ 
src                                   └─┘  └─┘            └──────┘   └──┘        └────┘
typ                                   └─┘  └─┘           └──────┘  └──┘       └────┘ 
doc                                                       └──────┘
248  { sets             := s,
id                         
typ                        
249    univ_sets        := hs ▸ (univ_mem_sets : univ ∈ generate s),
id                         └┘   └───────────┘   └──┘  └──────┘ 
src                             └───────────┘   └──┘  └──────┘
typ                        └┘   └───────────┘   └──┘  └──────┘ 
doc                                                     └──────┘
250    sets_of_superset := assume x y, hs ▸ (mem_sets_of_superset : x ∈ generate s → x ⊆ y → y ∈ generate s),
id                                   └┘   └──────────────────┘     └──────┘           └──────┘ 
src                                         └──────────────────┘      └──────┘               └──────┘
typ                                  └┘   └──────────────────┘     └──────┘           └──────┘ 
doc                                                                     └──────┘                 └──────┘
251    inter_sets       := assume x y, hs ▸ (inter_mem_sets : x ∈ generate s → y ∈ generate s → x ∩ y ∈ generate s) }
id                                   └┘   └────────────┘     └──────┘      └──────┘        └──────┘ 
src                                         └────────────┘      └──────┘        └──────┘           └──────┘
typ                                  └┘   └────────────┘     └──────┘      └──────┘        └──────┘ 
doc                                                               └──────┘         └──────┘             └──────┘
252  
253  lemma mk_of_closure_sets {s : set (set α)} {hs : (generate s).sets = s} :
id                                 └─┘  └─┘           └──────┘  └──┘   
src                                └─┘  └─┘            └──────┘   └──┘  
typ                                └─┘  └─┘           └──────┘  └──┘   
doc                                                    └──────┘
254    filter.mk_of_closure s hs = generate s :=
id     └──────────────────┘  └┘  └──────┘ 
src    └──────────────────┘       └──────┘
typ    └──────────────────┘  └┘  └──────┘ 
doc                                └──────┘
255  filter.ext $ assume u,
id   └────────┘          
src  └────────┘
typ  └────────┘          
256  show u ∈ (filter.mk_of_closure s hs).sets ↔ u ∈ (generate s).sets, from hs.symm ▸ iff.rfl
id           └──────────────────┘  └┘ └──┘      └──────┘  └──┘        └┘└───┘  └─────┘
src           └──────────────────┘      └──┘       └──────┘   └──┘          └───┘  └─────┘
typ          └──────────────────┘  └┘ └──┘      └──────┘  └──┘        └┘└───┘  └─────┘
doc                                                   └──────┘
257  
258  /- Galois insertion from sets of sets into a filters. -/
259  def gi_generate (α : Type*) :
260    @galois_insertion (set (set α)) (order_dual (filter α)) _ _ filter.generate filter.sets :=
id      └──────────────┘  └─┘  └─┘     └────────┘  └────┘        └─────────────┘ └─────────┘
src     └──────────────┘  └─┘  └─┘      └────────┘  └────┘         └─────────────┘ └─────────┘
typ     └──────────────┘  └─┘  └─┘     └────────┘  └────┘        └─────────────┘ └─────────┘
doc     └──────────────┘                └────────┘                 └─────────────┘
261  { gc        := assume s f, sets_iff_generate,
id                            └───────────────┘
src                             └───────────────┘
typ                           └───────────────┘
262    le_l_u    := assume f u h, generate_sets.basic h,
id                             └─────────────────┘ 
src                               └─────────────────┘
typ                            └─────────────────┘ 
263    choice    := λs hs, filter.mk_of_closure s (le_antisymm hs $ sets_iff_generate.1 $ le_refl _),
id                    └┘  └──────────────────┘   └─────────┘ └┘   └───────────────┘    └─────┘
src                        └──────────────────┘    └─────────┘      └───────────────┘    └─────┘
typ                   └┘  └──────────────────┘   └─────────┘ └┘   └───────────────┘    └─────┘
264    choice_eq := assume s hs, mk_of_closure_sets }
id                          └┘  └────────────────┘
src                              └────────────────┘
typ                         └┘  └────────────────┘
265  
266  /-- The infimum of filters is the filter generated by intersections
267    of elements of the two filters. -/
268  instance : has_inf (filter α) := ⟨λf g : filter α,
id              └─────┘  └────┘              └────┘ 
src             └─────┘  └────┘               └────┘
typ             └─────┘  └────┘              └────┘ 
doc             └─────┘
269  { sets             := {s | ∃ (a ∈ f) (b ∈ g), a ∩ b ⊆ s },
id                                             
src                                                  
typ                                            
270    univ_sets        := ⟨_, univ_mem_sets, _, univ_mem_sets, inter_subset_left _ _⟩,
id                             └───────────┘     └───────────┘  └───────────────┘
src                            └───────────┘     └───────────┘  └───────────────┘
typ                            └───────────┘     └───────────┘  └───────────────┘
271    sets_of_superset := assume x y ⟨a, ha, b, hb, h⟩ xy, ⟨a, ha, b, hb, subset.trans h xy⟩,
id                                    └┘    └┘    └┘                 └──────────┘   └┘
src                                                                        └──────────┘
typ                                   └┘    └┘    └┘                 └──────────┘   └┘
272    inter_sets       := assume x y ⟨a, ha, b, hb, hx⟩ ⟨c, hc, d, hd, hy⟩,
id                                    └┘    └┘  └┘    └┘    └┘  └┘
typ                                   └┘    └┘  └┘    └┘    └┘  └┘
273      ⟨_, inter_mem_sets ha hc, _, inter_mem_sets hb hd,
id           └────────────┘           └────────────┘
src          └────────────┘           └────────────┘
typ          └────────────┘           └────────────┘
274        calc a ∩ c ∩ (b ∩ d) = (a ∩ b) ∩ (c ∩ d) : by ac_refl
id                                        
src                                                └───────
typ                                                └───────
doc                                                      └───────
txt                                                      └───────
par                                                      └───────
pid                                                             
st                                                      └────────
275          ... ⊆ x ∩ y : inter_subset_inter hx hy⟩ }⟩
id                      └────────────────┘
src  ───────┘             └────────────────┘
typ  ───────┘           └────────────────┘
doc  ───────┘
txt  ───────┘
par  ───────┘
pid  ───────┘
st   ───────┘
276  
277  @[simp] lemma mem_inf_sets {f g : filter α} {s : set α} :
id                                     └────┘        └─┘ 
src                                    └────┘         └─┘
typ                                    └────┘        └─┘ 
doc    └──┘
278    s ∈ f ⊓ g ↔ ∃t₁∈f, ∃t₂∈g, t₁ ∩ t₂ ⊆ s := iff.rfl
id           └┘  └┘  └┘  └┘      └─────┘
src                                    └─────┘
typ          └┘  └┘  └┘  └┘      └─────┘
279  
280  lemma mem_inf_sets_of_left {f g : filter α} {s : set α} (h : s ∈ f) : s ∈ f ⊓ g :=
id                                     └────┘        └─┘                  
src                                    └────┘         └─┘                      
typ                                    └────┘        └─┘                  
281  ⟨s, h, univ, univ_mem_sets, inter_subset_left _ _⟩
id        └──┘  └───────────┘  └───────────────┘
src         └──┘  └───────────┘  └───────────────┘
typ       └──┘  └───────────┘  └───────────────┘
282  
283  lemma mem_inf_sets_of_right {f g : filter α} {s : set α} (h : s ∈ g) : s ∈ f ⊓ g :=
id                                      └────┘        └─┘                  
src                                     └────┘         └─┘                      
typ                                     └────┘        └─┘                  
284  ⟨univ, univ_mem_sets, s, h, inter_subset_right _ _⟩
id    └──┘  └───────────┘      └────────────────┘
src   └──┘  └───────────┘        └────────────────┘
typ   └──┘  └───────────┘      └────────────────┘
285  
286  lemma inter_mem_inf_sets {α : Type u} {f g : filter α} {s t : set α}
id                                                └────┘          └─┘ 
src                                               └────┘           └─┘
typ                                               └────┘          └─┘ 
287    (hs : s ∈ f) (ht : t ∈ g) : s ∩ t ∈ f ⊓ g :=
id                                 
src                                      
typ                                
288  inter_mem_sets (mem_inf_sets_of_left hs) (mem_inf_sets_of_right ht)
id   └────────────┘  └──────────────────┘ └┘   └───────────────────┘ └┘
src  └────────────┘  └──────────────────┘      └───────────────────┘
typ  └────────────┘  └──────────────────┘ └┘   └───────────────────┘ └┘
289  
290  instance : has_top (filter α) :=
id              └─────┘  └────┘ 
src             └─────┘  └────┘
typ             └─────┘  └────┘ 
doc             └─────┘
291  ⟨{ sets            := {s | ∀x, x ∈ s},
id                                 
src                                  
typ                                
292    univ_sets        := assume x, mem_univ x,
id                                  └──────┘ 
src                                  └──────┘
typ                                 └──────┘ 
293    sets_of_superset := assume x y hx hxy a, hxy (hx a),
id                                  └┘ └─┘   └─┘  └┘ 
typ                                 └┘ └─┘   └─┘  └┘ 
294    inter_sets       := assume x y hx hy a, mem_inter (hx _) (hy _) }⟩
id                                  └┘ └┘   └───────┘  └┘     └┘
src                                            └───────┘
typ                                 └┘ └┘   └───────┘  └┘     └┘
295  
296  lemma mem_top_sets_iff_forall {s : set α} : s ∈ (⊤ : filter α) ↔ (∀x, x ∈ s) :=
id                                      └─┘           └────┘          
src                                     └─┘             └────┘            
typ                                     └─┘           └────┘          
297  iff.rfl
id   └─────┘
src  └─────┘
typ  └─────┘
298  
299  @[simp] lemma mem_top_sets {s : set α} : s ∈ (⊤ : filter α) ↔ s = univ :=
id                                   └─┘           └────┘      └──┘
src                                  └─┘             └────┘        └──┘
typ                                  └─┘           └────┘      └──┘
doc    └──┘
300  by rw [mem_top_sets_iff_forall, eq_univ_iff_forall]
id          └─────────────────────┘  └────────────────┘
src     └──┘└─────────────────────┘└┘└────────────────┘└─
typ     └──┘└─────────────────────┘└┘└────────────────┘└─
doc     └──┘                       └┘                  └─
txt     └──┘                       └┘                  └─
par     └──┘                       └┘                  └─
pid       └┘                       └┘                  
st     └──────────────────────────┘└──────────────────┘
301  
src  
typ  
doc  
txt  
par  
pid  
st   
302  section complete_lattice
303  
304  /- We lift the complete lattice along the Galois connection `generate` / `sets`. Unfortunately,
305    we want to have different definitional equalities for the lattice operations. So we define them
306    upfront and change the lattice operations for the complete lattice instance. -/
307  
308  private def original_complete_lattice : complete_lattice (filter α) :=
id                                           └──────────────┘  └────┘ 
src                                          └──────────────┘  └────┘
typ                                          └──────────────┘  └────┘ 
doc                                          └──────────────┘
309  @order_dual.lattice.complete_lattice _ (gi_generate α).lift_complete_lattice
id    └─────────────────────────────────┘    └─────────┘  └───────────────────┘
src   └─────────────────────────────────┘    └─────────┘   └───────────────────┘
typ   └─────────────────────────────────┘    └─────────┘  └───────────────────┘
doc                                                        └───────────────────┘
310  
311  local attribute [instance] original_complete_lattice
id                              └───────────────────────┘
src                             └───────────────────────┘
typ                             └───────────────────────┘
312  
313  instance : complete_lattice (filter α) := original_complete_lattice.copy
id              └──────────────┘  └────┘      └───────────────────────┘└───┘
src             └──────────────┘  └────┘       └───────────────────────┘└───┘
typ             └──────────────┘  └────┘      └───────────────────────┘└───┘
doc             └──────────────┘
314    /- le  -/ filter.partial_order.le rfl
id               └──────────────────┘└─┘ └─┘
src              └──────────────────┘└─┘ └─┘
typ              └──────────────────┘└─┘ └─┘
315    /- top -/ (filter.lattice.has_top).1
id                └────────────────────┘ 
src               └────────────────────┘ 
typ               └────────────────────┘ 
316    (top_unique $ assume s hs, by have := univ_mem_sets ; finish)
id      └────────┘           └┘             └───────────┘
src     └────────┘                   └──────┘└───────────┘  └────┘
typ     └────────┘           └┘     └──────┘└───────────┘  └────┘
doc                                  └──────┘               └────┘
txt                                  └──────┘               └────┘
par                                  └──────┘               └────┘
pid                                  └───┘└─┘             
st                                  └─────────────────────────────┘
317    /- bot -/ _ rfl
id                 └─┘
src                └─┘
typ                └─┘
318    /- sup -/ _ rfl
id                 └─┘
src                └─┘
typ                └─┘
319    /- inf -/ (filter.lattice.has_inf).1
id                └────────────────────┘ 
src               └────────────────────┘ 
typ               └────────────────────┘ 
doc               └────────────────────┘
320    begin
st     └─────
321      ext f g : 2,
src      └─────────┘
typ      └─────────┘
doc      └─────────┘
txt      └─────────┘
par      └─────────┘
pid         └──┘└─┘
st   ──────────────┘└─
322      exact le_antisymm
id             └─────────┘
src      └────┘└─────────┘
typ      └────┘└─────────┘
doc      └────┘           
txt      └────┘           
par      └────┘           
pid                      
st   ──────────────────────
323        (le_inf (assume s, mem_inf_sets_of_left) (assume s, mem_inf_sets_of_right))
id          └────┘            └──────────────────┘             └───────────────────┘
src  ─────┘ └────┘       └──┘└──────────────────┘└┘       └──┘└───────────────────┘└──
typ  ─────┘ └────┘       └──┘└──────────────────┘└┘       └──┘└───────────────────┘└──
doc  ─────┘              └──┘                    └┘       └──┘                     └──
txt  ─────┘              └──┘                    └┘       └──┘                     └──
par  ─────┘              └──┘                    └┘       └──┘                     └──
pid  ─────┘              └──┘                    └┘       └──┘                     └──
st   ──────────────────────────────────────────────────────────────────────────────────
324        (assume s ⟨a, ha, b, hb, hs⟩, show s ∈ complete_lattice.inf f g, from
id                       └┘     └┘  └┘           └──────────────────┘  
src  ─────┘       └──┘ └┘  └┘ └┘  └┘  └─┘     └──────────────────┘  └──────
typ  ─────┘       └──┘ └┘└┘└┘ └┘└┘└┘└┘└─┘     └──────────────────┘└──────
doc  ─────┘       └──┘ └┘  └┘ └┘  └┘  └─┘                            └──────
txt  ─────┘       └──┘ └┘  └┘ └┘  └┘  └─┘                            └──────
par  ─────┘       └──┘ └┘  └┘ └┘  └┘  └─┘                            └──────
pid  ─────┘       └──┘ └┘  └┘ └┘  └┘  └─┘                            └──────
st   ────────────────────────────────────────────────────────────────────────────
325        mem_sets_of_superset (inter_mem_sets
id         └──────────────────┘  └────────────┘
src  ─────┘└──────────────────┘ └────────────┘
typ  ─────┘└──────────────────┘ └────────────┘
doc  ─────┘                                   
txt  ─────┘                                   
par  ─────┘                                   
pid  ─────┘                                   
st   ───────────────────────────────────────────
326          (@inf_le_left (filter α) _ _ _ _ ha)
id             └─────────┘
src  ───────┘  └─────────┘        └────────┘  └─
typ  ───────┘  └─────────┘        └────────┘  └─
doc  ───────┘                     └────────┘  └─
txt  ───────┘                     └────────┘  └─
par  ───────┘                     └────────┘  └─
pid  ───────┘                     └────────┘  └─
st   ─────────────────────────────────────────────
327          (@inf_le_right (filter α) _ _ _ _ hb)) hs)
id             └──────────┘  └────┘ 
src  ───────┘  └──────────┘ └────┘ └────────┘  └─┘  └─
typ  ───────┘  └──────────┘ └────┘└────────┘  └─┘  └─
doc  ───────┘                      └────────┘  └─┘  └─
txt  ───────┘                      └────────┘  └─┘  └─
par  ───────┘                      └────────┘  └─┘  └─
pid  ───────┘                      └────────┘  └─┘  
st   ───────────────────────────────────────────────────
328    end
src  ─┘
typ  ─┘
doc  ─┘
txt  ─┘
par  ─┘
pid  ─┘
st   ─┘└─┘
329    /- Sup -/ (join ∘ principal) (by ext s x; exact (@mem_bInter_iff _ _ s filter.sets x).symm)
id                └──┘  └───────┘                       └────────────┘      └─────────┘ 
src               └──┘  └───────┘      └─────┘  └────┘  └────────────┘└───┘ └─────────┘ └────┘
typ               └──┘  └───────┘      └─────┘  └────┘  └────────────┘└───┘└─────────┘└────┘
doc               └──┘   └───────┘      └─────┘  └────┘                └───┘             └────┘
txt                                     └─────┘  └────┘                └───┘             └────┘
par                                     └─────┘  └────┘                └───┘             └────┘
pid                                        └──┘                       └───┘             └───┘
st                                     └────────────────────────────────────────────────────────┘
330    /- Inf -/ _ rfl
id                 └─┘
src                └─┘
typ                └─┘
331  
332  end complete_lattice
333  
334  lemma bot_sets_eq : (⊥ : filter α).sets = univ := rfl
id                           └────┘  └──┘   └──┘    └─┘
src                          └────┘   └──┘   └──┘    └─┘
typ                          └────┘  └──┘   └──┘    └─┘
335  
336  lemma sup_sets_eq {f g : filter α} : (f ⊔ g).sets = f.sets ∩ g.sets :=
id                            └────┘         └──┘   └───┘  └───┘
src                           └────┘            └──┘    └───┘   └───┘
typ                           └────┘         └──┘   └───┘  └───┘
337  (gi_generate α).gc.u_inf
id    └─────────┘  └┘ └───┘
src   └─────────┘   └┘ └───┘
typ   └─────────┘  └┘ └───┘
338  
339  lemma Sup_sets_eq {s : set (filter α)} : (Sup s).sets = (⋂f∈s, (f:filter α).sets) :=
id                          └─┘  └────┘       └─┘  └──┘        └────┘  └──┘
src                         └─┘  └────┘        └─┘   └──┘           └────┘   └──┘
typ                         └─┘  └────┘       └─┘  └──┘        └────┘  └──┘
doc                                            └─┘               
340  (gi_generate α).gc.u_Inf
id    └─────────┘  └┘ └───┘
src   └─────────┘   └┘ └───┘
typ   └─────────┘  └┘ └───┘
341  
342  lemma supr_sets_eq {f : ι → filter α} : (supr f).sets = (⋂i, (f i).sets) :=
id                              └────┘      └──┘  └──┘        └──┘
src                              └────┘       └──┘   └──┘           └──┘
typ                             └────┘      └──┘  └──┘        └──┘
doc                                           └──┘             
343  (gi_generate α).gc.u_infi
id    └─────────┘  └┘ └────┘
src   └─────────┘   └┘ └────┘
typ   └─────────┘  └┘ └────┘
344  
345  lemma generate_empty : filter.generate ∅ = (⊤ : filter α) :=
id                          └─────────────┘       └────┘ 
src                         └─────────────┘       └────┘
typ                         └─────────────┘       └────┘ 
doc                         └─────────────┘
346  (gi_generate α).gc.l_bot
id    └─────────┘  └┘ └───┘
src   └─────────┘   └┘ └───┘
typ   └─────────┘  └┘ └───┘
347  
348  lemma generate_univ : filter.generate univ = (⊥ : filter α) :=
id                         └─────────────┘ └──┘      └────┘ 
src                        └─────────────┘ └──┘      └────┘
typ                        └─────────────┘ └──┘      └────┘ 
doc                        └─────────────┘
349  mk_of_closure_sets.symm
id   └────────────────┘└───┘
src  └────────────────┘└───┘
typ  └────────────────┘└───┘
350  
351  lemma generate_union {s t : set (set α)} :
id                               └─┘  └─┘ 
src                              └─┘  └─┘
typ                              └─┘  └─┘ 
352    filter.generate (s ∪ t) = filter.generate s ⊓ filter.generate t :=
id     └─────────────┘       └─────────────┘   └─────────────┘ 
src    └─────────────┘         └─────────────┘    └─────────────┘
typ    └─────────────┘       └─────────────┘   └─────────────┘ 
doc    └─────────────┘           └─────────────┘     └─────────────┘
353  (gi_generate α).gc.l_sup
id    └─────────┘  └┘ └───┘
src   └─────────┘   └┘ └───┘
typ   └─────────┘  └┘ └───┘
354  
355  lemma generate_Union {s : ι → set (set α)} :
id                                └─┘  └─┘ 
src                                └─┘  └─┘
typ                               └─┘  └─┘ 
356    filter.generate (⋃ i, s i) = (⨅ i, filter.generate (s i)) :=
id     └─────────────┘           └─────────────┘   
src    └─────────────┘               └─────────────┘
typ    └─────────────┘           └─────────────┘   
doc    └─────────────┘                └─────────────┘
357  (gi_generate α).gc.l_supr
id    └─────────┘  └┘ └────┘
src   └─────────┘   └┘ └────┘
typ   └─────────┘  └┘ └────┘
358  
359  @[simp] lemma mem_bot_sets {s : set α} : s ∈ (⊥ : filter α) :=
id                                   └─┘           └────┘ 
src                                  └─┘             └────┘
typ                                  └─┘           └────┘ 
doc    └──┘
360  trivial
id   └─────┘
src  └─────┘
typ  └─────┘
361  
362  @[simp] lemma mem_sup_sets {f g : filter α} {s : set α} :
id                                     └────┘        └─┘ 
src                                    └────┘         └─┘
typ                                    └────┘        └─┘ 
doc    └──┘
363    s ∈ f ⊔ g ↔ s ∈ f ∧ s ∈ g :=
id                 
src                     
typ                
364  iff.rfl
id   └─────┘
src  └─────┘
typ  └─────┘
365  
366  @[simp] lemma mem_Sup_sets {x : set α} {s : set (filter α)} :
id                                   └─┘        └─┘  └────┘ 
src                                  └─┘         └─┘  └────┘
typ                                  └─┘        └─┘  └────┘ 
doc    └──┘
367    x ∈ Sup s ↔ (∀f∈s, x ∈ (f:filter α)) :=
id       └─┘            └────┘ 
src       └─┘                 └────┘
typ      └─┘            └────┘ 
doc        └─┘
368  iff.rfl
id   └─────┘
src  └─────┘
typ  └─────┘
369  
370  @[simp] lemma mem_supr_sets {x : set α} {f : ι → filter α} :
id                                    └─┘           └────┘ 
src                                   └─┘             └────┘
typ                                   └─┘           └────┘ 
doc    └──┘
371    x ∈ supr f ↔ (∀i, x ∈ f i) :=
id       └──┘          
src       └──┘           
typ      └──┘          
doc        └──┘
372  by simp only [supr_sets_eq, iff_self, mem_Inter]
id                 └──────────┘  └──────┘  └───────┘
src     └─────────┘└──────────┘└┘└──────┘└┘└───────┘└─
typ     └─────────┘└──────────┘└┘└──────┘└┘└───────┘└─
doc     └─────────┘            └┘        └┘         └─
txt     └─────────┘            └┘        └┘         └─
par     └─────────┘            └┘        └┘         └─
pid         └──┘└┘            └┘        └┘         
st     └──────────────────────────────────────────────
373  
src  
typ  
doc  
txt  
par  
pid  
st   
374  @[simp] lemma le_principal_iff {s : set α} {f : filter α} : f ≤ principal s ↔ s ∈ f :=
id                                       └─┘        └────┘       └───────┘     
src                                      └─┘         └────┘         └───────┘      
typ                                      └─┘        └────┘       └───────┘     
doc    └──┘                                                          └───────┘
375  show (∀{t}, s ⊆ t → t ∈ f) ↔ s ∈ f,
id                          
src                              
typ                         
376    from ⟨assume h, h (subset.refl s), assume hs t ht, mem_sets_of_superset hs ht⟩
id                      └─────────┘           └┘  └┘  └──────────────────┘ └┘ └┘
src                       └─────────┘                     └──────────────────┘
typ                     └─────────┘           └┘  └┘  └──────────────────┘ └┘ └┘
377  
378  lemma principal_mono {s t : set α} : principal s ≤ principal t ↔ s ⊆ t :=
id                               └─┘     └───────┘   └───────┘     
src                              └─┘      └───────┘    └───────┘      
typ                              └─┘     └───────┘   └───────┘     
doc                                       └───────┘     └───────┘
379  by simp only [le_principal_iff, iff_self, mem_principal_sets]
id                 └──────────────┘  └──────┘  └────────────────┘
src     └─────────┘└──────────────┘└┘└──────┘└┘└────────────────┘└─
typ     └─────────┘└──────────────┘└┘└──────┘└┘└────────────────┘└─
doc     └─────────┘                └┘        └┘                  └─
txt     └─────────┘                └┘        └┘                  └─
par     └─────────┘                └┘        └┘                  └─
pid         └──┘└┘                └┘        └┘                  
st     └───────────────────────────────────────────────────────────
380  
src  
typ  
doc  
txt  
par  
pid  
st   
381  lemma monotone_principal : monotone (principal : set α → filter α) :=
id                              └──────┘  └───────┘   └─┘    └────┘ 
src                             └──────┘  └───────┘   └─┘     └────┘
typ                             └──────┘  └───────┘   └─┘    └────┘ 
doc                             └──────┘  └───────┘
382  λ _ _, principal_mono.2
id        └────────────┘
src         └────────────┘
typ       └────────────┘
383  
384  @[simp] lemma principal_eq_iff_eq {s t : set α} : principal s = principal t ↔ s = t :=
id                                            └─┘     └───────┘   └───────┘     
src                                           └─┘      └───────┘    └───────┘      
typ                                           └─┘     └───────┘   └───────┘     
doc    └──┘                                            └───────┘     └───────┘
385  by simp only [le_antisymm_iff, le_principal_iff, mem_principal_sets]; refl
id                 └─────────────┘  └──────────────┘  └────────────────┘
src     └─────────┘└─────────────┘└┘└──────────────┘└┘└────────────────┘  └────
typ     └─────────┘└─────────────┘└┘└──────────────┘└┘└────────────────┘  └────
doc     └─────────┘               └┘                └┘                    └────
txt     └─────────┘               └┘                └┘                    └────
par     └─────────┘               └┘                └┘                    └────
pid         └──┘└┘               └┘                └┘                        
st     └────────────────────────────────────────────────────────────────────────
386  
src  
typ  
doc  
txt  
par  
pid  
st   
387  @[simp] lemma join_principal_eq_Sup {s : set (filter α)} : join (principal s) = Sup s := rfl
id                                            └─┘  └────┘      └──┘  └───────┘    └─┘     └─┘
src                                           └─┘  └────┘       └──┘  └───────┘     └─┘      └─┘
typ                                           └─┘  └────┘      └──┘  └───────┘    └─┘     └─┘
doc    └──┘                                                     └──┘  └───────┘      └─┘
388  
389  /- lattice equations -/
390  
391  lemma empty_in_sets_eq_bot {f : filter α} : ∅ ∈ f ↔ f = ⊥ :=
id                                   └────┘           
src                                  └────┘              
typ                                  └────┘           
392  ⟨assume h, bot_unique $ assume s _, mem_sets_of_superset h (empty_subset s),
id             └────────┘             └──────────────────┘   └──────────┘ 
src             └────────┘               └──────────────────┘    └──────────┘
typ            └────────┘             └──────────────────┘   └──────────┘ 
393    assume : f = ⊥, this.symm ▸ mem_bot_sets⟩
id                  └──┘└───┘  └──────────┘
src                      └───┘  └──────────┘
typ                 └──┘└───┘  └──────────┘
394  
395  lemma nonempty_of_mem_sets {f : filter α} (hf : f ≠ ⊥) {s : set α} (hs : s ∈ f) :
id                                   └────┘                  └─┘           
src                                  └────┘                    └─┘            
typ                                  └────┘                  └─┘           
396    s.nonempty :=
id     └───────┘
src     └───────┘
typ    └───────┘
doc     └───────┘
397  s.eq_empty_or_nonempty.elim (λ h, absurd hs (h.symm ▸ mt empty_in_sets_eq_bot.mp hf)) id
id   └───────────────────┘└───┘      └────┘ └┘  └───┘  └┘ └──────────────────┘└─┘ └┘   └┘
src   └───────────────────┘└───┘       └────┘      └───┘  └┘ └──────────────────┘└─┘      └┘
typ  └───────────────────┘└───┘      └────┘ └┘  └───┘  └┘ └──────────────────┘└─┘ └┘   └┘
398  
399  lemma filter_eq_bot_of_not_nonempty {f : filter α} (ne : ¬ nonempty α) : f = ⊥ :=
id                                            └────┘          └──────┘       
src                                           └────┘           └──────┘         
typ                                           └────┘          └──────┘       
400  empty_in_sets_eq_bot.mp $ univ_mem_sets' $ assume x, false.elim (ne ⟨x⟩)
id   └──────────────────┘└─┘   └────────────┘            └────────┘  └┘  
src  └──────────────────┘└─┘   └────────────┘             └────────┘  └┘
typ  └──────────────────┘└─┘   └────────────┘            └────────┘  └┘  
401  
402  lemma forall_sets_nonempty_iff_ne_bot {f : filter α} :
id                                              └────┘ 
src                                             └────┘
typ                                             └────┘ 
403    (∀ (s : set α), s ∈ f → s.nonempty) ↔ f ≠ ⊥ :=
id             └─┘         └───────┘     
src            └─┘             └───────┘      
typ            └─┘         └───────┘     
doc                             └───────┘
404  ⟨λ h hf, empty_not_nonempty (h ∅ $ hf.symm ▸ mem_bot_sets), nonempty_of_mem_sets⟩
id       └┘  └────────────────┘      └┘└───┘  └──────────┘   └──────────────────┘
src           └────────────────┘         └───┘  └──────────┘   └──────────────────┘
typ      └┘  └────────────────┘      └┘└───┘  └──────────┘   └──────────────────┘
405  
406  lemma mem_sets_of_eq_bot {f : filter α} {s : set α} (h : f ⊓ principal (-s) = ⊥) : s ∈ f :=
id                                 └────┘        └─┘          └───────┘           
src                                └────┘         └─┘            └───────┘            
typ                                └────┘        └─┘          └───────┘           
doc                                                               └───────┘
407  have ∅ ∈ f ⊓ principal (- s), from h.symm ▸ mem_bot_sets,
id            └───────┘           └───┘  └──────────┘
src            └───────┘             └───┘  └──────────┘
typ           └───────┘           └───┘  └──────────┘
doc               └───────┘
408  let ⟨s₁, hs₁, s₂, (hs₂ : -s ⊆ s₂), (hs : s₁ ∩ s₂ ⊆ ∅)⟩ := this in
id   └─┘                                                 └──┘
src                                                 
typ  └─┘                                                 └──┘
409  by filter_upwards [hs₁] assume a ha, classical.by_contradiction $ assume ha', hs ⟨ha, hs₂ ha'⟩
id                                        └────────────────────────┘               └┘      └─┘
src     └──────────────┘   └┘      └─────┘└────────────────────────┘       └────┘     └┘      └─
typ     └──────────────┘   └┘      └─────┘└────────────────────────┘       └────┘└┘   └┘└─┘   └─
doc     └──────────────┘   └┘      └─────┘                                 └────┘     └┘      └─
txt     └──────────────┘   └┘      └─────┘                                 └────┘     └┘      └─
par     └──────────────┘   └┘      └─────┘                                 └────┘     └┘      └─
pid                   └┘         └─────┘                                 └────┘     └┘      
st     └────────────────────────────────────────────────────────────────────────────────────────────
410  
src  
typ  
doc  
txt  
par  
pid  
st   
411  lemma eq_Inf_of_mem_sets_iff_exists_mem {S : set (filter α)} {l : filter α}
id                                                └─┘  └────┘         └────┘ 
src                                               └─┘  └────┘          └────┘
typ                                               └─┘  └────┘         └────┘ 
412    (h : ∀ {s}, s ∈ l ↔ ∃ f ∈ S, s ∈ f) : l = Inf S :=
id                                 └─┘ 
src                                        └─┘
typ                                └─┘ 
doc                                              └─┘
413  le_antisymm (le_Inf $ λ f hf s hs, h.2 ⟨f, hf, hs⟩)
id   └─────────┘  └────┘      └┘  └┘       └┘  └┘
src  └─────────┘  └────┘                 
typ  └─────────┘  └────┘      └┘  └┘       └┘  └┘
414    (λ s hs, let ⟨f, hf, hs⟩ := h.1 hs in (Inf_le hf : Inf S ≤ f) hs)
id         └┘  └─┘    └┘  └┘       └┘     └────┘      └─┘  
src                                          └────┘      └─┘   
typ        └┘  └─┘    └┘  └┘       └┘     └────┘      └─┘  
doc                                                       └─┘
415  
416  lemma eq_infi_of_mem_sets_iff_exists_mem {f : ι → filter α} {l : filter α}
id                                                    └────┘        └────┘ 
src                                                    └────┘         └────┘
typ                                                   └────┘        └────┘ 
417    (h : ∀ {s}, s ∈ l ↔ ∃ i, s ∈ f i) :
id                         
src                           
typ                        
418    l = infi f :=
id       └──┘ 
src       └──┘
typ      └──┘ 
doc        └──┘
419  eq_Inf_of_mem_sets_iff_exists_mem $ λ s, h.trans exists_range_iff.symm
id   └───────────────────────────────┘       └────┘ └──────────────┘└───┘
src  └───────────────────────────────┘         └────┘ └──────────────┘└───┘
typ  └───────────────────────────────┘       └────┘ └──────────────┘└───┘
420  
421  lemma eq_binfi_of_mem_sets_iff_exists_mem {f : ι → filter α} {p : ι  → Prop} {l : filter α}
id                                                     └────┘                       └────┘ 
src                                                     └────┘                         └────┘
typ                                                    └────┘                       └────┘ 
422    (h : ∀ {s}, s ∈ l ↔ ∃ i (_ : p i), s ∈ f i) :
id                                 
src                                     
typ                                
423    l = ⨅ i (_ : p i), f i :=
id                  
src                   
typ                 
doc                    
424  begin
st   └─────
425    rw [infi_subtype'],
id         └───────────┘
src    └──┘└───────────┘
typ    └──┘└───────────┘
doc    └──┘             
txt    └──┘             
par    └──┘             
pid      └┘             
st   ──────────────────┘└──
426    apply eq_infi_of_mem_sets_iff_exists_mem,
id           └────────────────────────────────┘
src    └────┘└────────────────────────────────┘
typ    └────┘└────────────────────────────────┘
doc    └────┘
txt    └────┘
par    └────┘
pid         
st   ─────────────────────────────────────────┘└─
427    intro s,
src    └─────┘
typ    └─────┘
doc    └─────┘
txt    └─────┘
par    └─────┘
pid         └┘
st   ────────┘└─
428    exact h.trans ⟨λ ⟨i, pi, si⟩, ⟨⟨i, pi⟩, si⟩, λ ⟨⟨i, pi⟩, si⟩, ⟨i, pi, si⟩⟩
id           └─────┘       └┘  └┘                        └┘   └┘
src    └────┘└─────┘  └┘ └┘  └┘  └─┘   └┘  └─┘  └─┘ └┘  └┘  └─┘  └─┘  └┘  └┘  └─┘
typ    └────┘└─────┘  └┘└┘└┘└┘└┘└─┘   └┘  └─┘  └─┘ └┘ └┘└┘└─┘└┘└─┘  └┘  └┘  └─┘
doc    └────┘         └┘ └┘  └┘  └─┘   └┘  └─┘  └─┘ └┘  └┘  └─┘  └─┘  └┘  └┘  └─┘
txt    └────┘         └┘ └┘  └┘  └─┘   └┘  └─┘  └─┘ └┘  └┘  └─┘  └─┘  └┘  └┘  └─┘
par    └────┘         └┘ └┘  └┘  └─┘   └┘  └─┘  └─┘ └┘  └┘  └─┘  └─┘  └┘  └┘  └─┘
pid                  └┘ └┘  └┘  └─┘   └┘  └─┘  └─┘ └┘  └┘  └─┘  └─┘  └┘  └┘  └┘
st   ────────────────────────────────────────────────────────────────────────────┘
429  end
st   └─┘
430  
431  lemma infi_sets_eq {f : ι → filter α} (h : directed (≥) f) (ne : nonempty ι) :
id                              └────┘        └──────┘            └──────┘ 
src                              └────┘         └──────┘             └──────┘
typ                             └────┘        └──────┘            └──────┘ 
doc                                             └──────┘
432    (infi f).sets = (⋃ i, (f i).sets) :=
id      └──┘  └──┘         └──┘
src     └──┘   └──┘            └──┘
typ     └──┘  └──┘         └──┘
doc     └──┘              
433  let ⟨i⟩ := ne, u := { filter .
id   └─┘        └┘  
src             └┘
typ  └─┘        └┘  
434      sets             := (⋃ i, (f i).sets),
id                                 └──┘
src                                   └──┘
typ                                └──┘
doc                             
435      univ_sets        := by simp only [mem_Union]; exact ⟨i, univ_mem_sets⟩,
id                                         └───────┘            └───────────┘
src                             └─────────┘└───────┘  └────┘  └┘└───────────┘
typ                             └─────────┘└───────┘  └────┘ └┘└───────────┘
doc                             └─────────┘           └────┘  └┘             
txt                             └─────────┘           └────┘  └┘             
par                             └─────────┘           └────┘  └┘             
pid                                 └──┘└┘                  └┘             
st                             └──────────────────────────────────────────────┘
436      sets_of_superset := by simp only [mem_Union, exists_imp_distrib];
id                                         └───────┘  └────────────────┘
src                             └─────────┘└───────┘└┘└────────────────┘
typ                             └─────────┘└───────┘└┘└────────────────┘
doc                             └─────────┘         └┘                  
txt                             └─────────┘         └┘                  
par                             └─────────┘         └┘                  
pid                                 └──┘└┘         └┘                  
st                             └───────────────────────────────────────────
437                          intros x y i hx hxy; exact ⟨i, mem_sets_of_superset hx hxy⟩,
id                                                         └──────────────────┘ └┘ └─┘
src                          └─────────────────┘  └────┘  └┘└──────────────────┘     
typ                          └─────────────────┘  └────┘ └┘└──────────────────┘└┘└─┘
doc                          └─────────────────┘  └────┘  └┘                         
txt                          └─────────────────┘  └────┘  └┘                         
par                          └─────────────────┘  └────┘  └┘                         
pid                                └───────────┘         └┘                         
st   ──────────────────────────────────────────────────────────────────────────────────┘
438      inter_sets       :=
439      begin
st       └─────
440        simp only [mem_Union, exists_imp_distrib],
id                    └───────┘  └────────────────┘
src        └─────────┘└───────┘└┘└────────────────┘
typ        └─────────┘└───────┘└┘└────────────────┘
doc        └─────────┘         └┘                  
txt        └─────────┘         └┘                  
par        └─────────┘         └┘                  
pid            └──┘└┘         └┘                  
st   ──────────────────────────────────────────────┘└─
441        assume x y a hx b hy,
src        └──────────────────┘
typ        └──────────────────┘
doc        └──────────────────┘
txt        └──────────────────┘
par        └──────────────────┘
pid        └──────────────────┘
st   ─────────────────────────┘└─
442        rcases h a b with ⟨c, ha, hb⟩,
id                  
src        └─────┘   └───────────────┘
typ        └─────┘└───────────────┘
doc        └─────┘   └───────────────┘
txt        └─────┘   └───────────────┘
par        └─────┘   └───────────────┘
pid                 └───────────────┘
st   ──────────────────────────────────┘└─
443        exact ⟨c, inter_mem_sets (ha hx) (hb hy)⟩
id                  └────────────┘  └┘ └┘   └┘ └┘
src        └────┘  └┘└────────────┘     └┘     └──
typ        └────┘ └┘└────────────┘ └┘└┘└┘ └┘└┘└──
doc        └────┘  └┘                   └┘     └──
txt        └────┘  └┘                   └┘     └──
par        └────┘  └┘                   └┘     └──
pid               └┘                   └┘     └┘
st   ────────────────────────────────────────────────
444      end } in
src  ───┘
typ  ───┘
doc  ───┘
txt  ───┘
par  ───┘
pid  ───┘
st   ───┘└─┘
445  have u = infi f, from eq_infi_of_mem_sets_iff_exists_mem (λ s, by simp only [mem_Union]),
id          └──┘        └────────────────────────────────┘                    └───────┘
src          └──┘         └────────────────────────────────┘          └─────────┘└───────┘
typ         └──┘        └────────────────────────────────┘         └─────────┘└───────┘
doc           └──┘                                                     └─────────┘         
txt                                                                    └─────────┘         
par                                                                    └─────────┘         
pid                                                                        └──┘└┘         
st                                                                    └────────────────────┘
446  congr_arg filter.sets this.symm
id   └───────┘ └─────────┘ └──┘└───┘
src  └───────┘ └─────────┘     └───┘
typ  └───────┘ └─────────┘ └──┘└───┘
447  
448  lemma mem_infi {f : ι → filter α} (h : directed (≥) f) (ne : nonempty ι) (s) :
id                          └────┘        └──────┘            └──────┘ 
src                          └────┘         └──────┘             └──────┘
typ                         └────┘        └──────┘            └──────┘ 
doc                                         └──────┘
449    s ∈ infi f ↔ ∃ i, s ∈ f i :=
id       └──┘        
src       └──┘         
typ      └──┘        
doc        └──┘
450  by simp only [infi_sets_eq h ne, mem_Union]
id                 └──────────┘  └┘  └───────┘
src     └─────────┘└──────────┘ └┘└┘└───────┘└─
typ     └─────────┘└──────────┘└┘└┘└───────┘└─
doc     └─────────┘               └┘         └─
txt     └─────────┘               └┘         └─
par     └─────────┘               └┘         └─
pid         └──┘└┘               └┘         
st     └─────────────────────────────────────────
451  
src  
typ  
doc  
txt  
par  
pid  
st   
452  @[nolint] -- Intentional use of `≥`
doc    └────┘
453  lemma binfi_sets_eq {f : β → filter α} {s : set β}
id                               └────┘        └─┘ 
src                               └────┘         └─┘
typ                              └────┘        └─┘ 
454    (h : directed_on (f ⁻¹'o (≥)) s) (ne : s.nonempty) :
id          └─────────┘   └──┘             └───────┘
src         └─────────┘    └──┘               └───────┘
typ         └─────────┘   └──┘             └───────┘
doc         └─────────┘    └──┘                └───────┘
455    (⨅ i∈s, f i).sets = (⋃ i ∈ s, (f i).sets) :=
id           └──┘            └──┘
src              └──┘                └──┘
typ          └──┘            └──┘
doc                             
456  let ⟨i, hi⟩ := ne in
id   └─┘    └┘     └┘
src                 └┘
typ  └─┘    └┘     └┘
457  calc (⨅ i ∈ s, f i).sets  = (⨅ t : {t // t ∈ s}, (f t.val)).sets : by rw [infi_subtype]; refl
id                └──┘                     └──┘  └──┘           └──────────┘
src                   └──┘                          └──┘  └──┘       └──┘└──────────┘  └────
typ               └──┘                     └──┘  └──┘       └──┘└──────────┘  └────
doc                                                                    └──┘              └────
txt                                                                        └──┘              └────
par                                                                        └──┘              └────
pid                                                                          └┘                  
st                                                                        └───────────────┘└──────
458    ... = (⨆ t : {t // t ∈ s}, (f t.val).sets) : infi_sets_eq
id                           └──┘ └──┘     └──────────┘
src  ─┘                           └──┘ └──┘     └──────────┘
typ  ─┘                      └──┘ └──┘     └──────────┘
doc  ─┘                        
txt  ─┘
par  ─┘
pid  ─┘
st   ─┘
459      (assume ⟨x, hx⟩ ⟨y, hy⟩, match h x hx y hy with ⟨z, h₁, h₂, h₃⟩ := ⟨⟨z, h₁⟩, h₂, h₃⟩ end)
id                 └┘    └┘                            └┘  └┘  └┘
typ                └┘    └┘                            └┘  └┘  └┘
460      ⟨⟨i, hi⟩⟩
461    ... = (⨆ t ∈ {t | t ∈ s}, (f t).sets) : by rw [supr_subtype]; refl
id                          └──┘            └──────────┘
src                               └──┘        └──┘└──────────┘  └────
typ                         └──┘        └──┘└──────────┘  └────
doc                                             └──┘              └────
txt                                               └──┘              └────
par                                               └──┘              └────
pid                                                 └┘                  
st                                               └───────────────┘└──────
462  
src  
typ  
doc  
txt  
par  
pid  
st   
463  @[nolint] -- Intentional use of `≥`
doc    └────┘
464  lemma mem_binfi {f : β → filter α} {s : set β}
id                           └────┘        └─┘ 
src                           └────┘         └─┘
typ                          └────┘        └─┘ 
465    (h : directed_on (f ⁻¹'o (≥)) s) (ne : s.nonempty) {t : set α} :
id          └─────────┘   └──┘             └───────┘       └─┘ 
src         └─────────┘    └──┘               └───────┘       └─┘
typ         └─────────┘   └──┘             └───────┘       └─┘ 
doc         └─────────┘    └──┘                └───────┘
466    t ∈ (⨅ i∈s, f i) ↔ ∃ i ∈ s, t ∈ f i :=
id                       
src                            
typ                      
doc             
467  by simp only [binfi_sets_eq h ne, mem_bUnion_iff]
id                 └───────────┘  └┘  └────────────┘
src     └─────────┘└───────────┘ └┘└┘└────────────┘└─
typ     └─────────┘└───────────┘└┘└┘└────────────┘└─
doc     └─────────┘                └┘              └─
txt     └─────────┘                └┘              └─
par     └─────────┘                └┘              └─
pid         └──┘└┘                └┘              
st     └───────────────────────────────────────────────
468  
src  
typ  
doc  
txt  
par  
pid  
st   
469  lemma infi_sets_eq_finite (f : ι → filter α) :
id                                     └────┘ 
src                                     └────┘
typ                                    └────┘ 
470    (⨅i, f i).sets = (⋃t:finset (plift ι), (⨅i∈t, f (plift.down i)).sets) :=
id         └──┘      └────┘  └───┘        └────────┘   └──┘
src           └──┘      └────┘  └───┘            └────────┘    └──┘
typ        └──┘      └────┘  └───┘        └────────┘   └──┘
doc                      └────┘  └───┘        
471  begin
st   └─────
472    rw [infi_eq_infi_finset, infi_sets_eq],
id         └─────────────────┘  └──────────┘
src    └──┘└─────────────────┘└┘└──────────┘
typ    └──┘└─────────────────┘└┘└──────────┘
doc    └──┘                   └┘            
txt    └──┘                   └┘            
par    └──┘                   └┘            
pid      └┘                   └┘            
st   ────────────────────────┘└────────────┘└──
473    exact (directed_of_sup $ λs₁ s₂ hs, infi_le_infi $ λi, infi_le_infi_const $ λh, hs h),
id            └─────────────┘              └──────────┘       └────────────────┘
src    └────┘ └─────────────┘  └────────┘└──────────┘  └─┘└────────────────┘  └─┘   
typ    └────┘ └─────────────┘  └────────┘└──────────┘  └─┘└────────────────┘  └─┘   
doc    └────┘                  └────────┘              └─┘                    └─┘   
txt    └────┘                  └────────┘              └─┘                    └─┘   
par    └────┘                  └────────┘              └─┘                    └─┘   
pid                           └────────┘              └─┘                    └─┘   
st   ──────────────────────────────────────────────────────────────────────────────────────┘└─
474    apply_instance
src    └─────────────┘
typ    └─────────────┘
doc    └─────────────┘
txt    └─────────────┘
par    └─────────────┘
pid                  
st   ────────────────┘
475  end
st   └─┘
476  
477  lemma mem_infi_finite {f : ι → filter α} (s) :
id                                 └────┘ 
src                                 └────┘
typ                                └────┘ 
478    s ∈ infi f ↔ s ∈ ⋃t:finset (plift ι), (⨅i∈t, f (plift.down i)).sets :=
id       └──┘       └────┘  └───┘        └────────┘   └──┘
src       └──┘         └────┘  └───┘            └────────┘    └──┘
typ      └──┘       └────┘  └───┘        └────────┘   └──┘
doc        └──┘           └────┘  └───┘        
479  show  s ∈ (infi f).sets ↔ s ∈ ⋃t:finset (plift ι), (⨅i∈t, f (plift.down i)).sets,
id            └──┘  └──┘       └────┘  └───┘        └────────┘   └──┘
src            └──┘   └──┘        └────┘  └───┘            └────────┘    └──┘
typ           └──┘  └──┘       └────┘  └───┘        └────────┘   └──┘
doc             └──┘                 └────┘  └───┘        
480  by rw infi_sets_eq_finite
id         └─────────────────┘
src     └─┘└─────────────────┘
typ     └─┘└─────────────────┘
doc     └─┘                   
txt     └─┘                   
par     └─┘                   
pid                          
st     └───────────────────────
481  
src  
typ  
doc  
txt  
par  
pid  
st   
482  @[simp] lemma sup_join {f₁ f₂ : filter (filter α)} : (join f₁ ⊔ join f₂) = join (f₁ ⊔ f₂) :=
id                                   └────┘  └────┘       └──┘ └┘  └──┘ └┘   └──┘  └┘  └┘
src                                  └────┘  └────┘        └──┘     └──┘      └──┘     
typ                                  └────┘  └────┘       └──┘ └┘  └──┘ └┘   └──┘  └┘  └┘
doc    └──┘                                                └──┘      └──┘       └──┘
483  filter_eq $ set.ext $ assume x,
id   └───────┘   └─────┘          
src  └───────┘   └─────┘
typ  └───────┘   └─────┘          
484    by simp only [supr_sets_eq, join, mem_sup_sets, iff_self, mem_set_of_eq]
id                   └──────────┘  └──┘  └──────────┘  └──────┘  └───────────┘
src       └─────────┘└──────────┘└┘└──┘└┘└──────────┘└┘└──────┘└┘└───────────┘└─
typ       └─────────┘└──────────┘└┘└──┘└┘└──────────┘└┘└──────┘└┘└───────────┘└─
doc       └─────────┘            └┘└──┘└┘            └┘        └┘             └─
txt       └─────────┘            └┘    └┘            └┘        └┘             └─
par       └─────────┘            └┘    └┘            └┘        └┘             └─
pid           └──┘└┘            └┘    └┘            └┘        └┘             
st       └──────────────────────────────────────────────────────────────────────
485  
src  
typ  
doc  
txt  
par  
pid  
st   
486  @[simp] lemma supr_join {ι : Sort w} {f : ι → filter (filter α)} :
id                                                └────┘  └────┘ 
src                                                └────┘  └────┘
typ                                               └────┘  └────┘ 
doc    └──┘
487    (⨆x, join (f x)) = join (⨆x, f x) :=
id       └──┘       └──┘    
src       └──┘         └──┘   
typ      └──┘       └──┘    
doc       └──┘          └──┘   
488  filter_eq $ set.ext $ assume x,
id   └───────┘   └─────┘          
src  └───────┘   └─────┘
typ  └───────┘   └─────┘          
489    by simp only [supr_sets_eq, join, iff_self, mem_Inter, mem_set_of_eq]
id                   └──────────┘  └──┘  └──────┘  └───────┘  └───────────┘
src       └─────────┘└──────────┘└┘└──┘└┘└──────┘└┘└───────┘└┘└───────────┘└─
typ       └─────────┘└──────────┘└┘└──┘└┘└──────┘└┘└───────┘└┘└───────────┘└─
doc       └─────────┘            └┘└──┘└┘        └┘         └┘             └─
txt       └─────────┘            └┘    └┘        └┘         └┘             └─
par       └─────────┘            └┘    └┘        └┘         └┘             └─
pid           └──┘└┘            └┘    └┘        └┘         └┘             
st       └───────────────────────────────────────────────────────────────────
490  
src  
typ  
doc  
txt  
par  
pid  
st   
491  instance : bounded_distrib_lattice (filter α) :=
id              └─────────────────────┘  └────┘ 
src             └─────────────────────┘  └────┘
typ             └─────────────────────┘  └────┘ 
doc             └─────────────────────┘
492  { le_sup_inf :=
493    begin
st     └─────
494      assume x y z s,
src      └────────────┘
typ      └────────────┘
doc      └────────────┘
txt      └────────────┘
par      └────────────┘
pid      └────────────┘
st   ─────────────────┘└─
495      simp only [and_assoc, mem_inf_sets, mem_sup_sets, exists_prop, exists_imp_distrib, and_imp],
id                  └───────┘  └──────────┘  └──────────┘  └─────────┘  └────────────────┘  └─────┘
src      └─────────┘└───────┘└┘└──────────┘└┘└──────────┘└┘└─────────┘└┘└────────────────┘└┘└─────┘
typ      └─────────┘└───────┘└┘└──────────┘└┘└──────────┘└┘└─────────┘└┘└────────────────┘└┘└─────┘
doc      └─────────┘         └┘            └┘            └┘           └┘                  └┘       
txt      └─────────┘         └┘            └┘            └┘           └┘                  └┘       
par      └─────────┘         └┘            └┘            └┘           └┘                  └┘       
pid          └──┘└┘         └┘            └┘            └┘           └┘                  └┘       
st   ──────────────────────────────────────────────────────────────────────────────────────────────┘└─
496      intros hs t₁ ht₁ t₂ ht₂ hts,
src      └─────────────────────────┘
typ      └─────────────────────────┘
doc      └─────────────────────────┘
txt      └─────────────────────────┘
par      └─────────────────────────┘
pid            └───────────────────┘
st   ──────────────────────────────┘└─
497      exact ⟨s ∪ t₁,
id                 └┘
src      └────┘    └─
typ      └────┘  └┘└─
doc      └────┘     └─
txt      └────┘     └─
par      └────┘     └─
pid                └─
st   ───────────────────
498        x.sets_of_superset hs $ subset_union_left _ _,
src  ─────┘                                      └─────
typ  ─────┘                                      └─────
doc  ─────┘                                      └─────
txt  ─────┘                                      └─────
par  ─────┘                                      └─────
pid  ─────┘                                      └─────
st   ─────────────────────────────────────────────────────
499        y.sets_of_superset ht₁ $ subset_union_right _ _,
id         └────────────────┘ └─┘
src  ─────┘└────────────────┘                      └─────
typ  ─────┘└────────────────┘└─┘                   └─────
doc  ─────┘                                        └─────
txt  ─────┘                                        └─────
par  ─────┘                                        └─────
pid  ─────┘                                        └─────
st   ───────────────────────────────────────────────────────
500        s ∪ t₂,
id            └┘
src  ─────┘    └─
typ  ─────┘ └┘└─
doc  ─────┘    └─
txt  ─────┘    └─
par  ─────┘    └─
pid  ─────┘    └─
st   ──────────────
501        x.sets_of_superset hs $ subset_union_left _ _,
id         └────────────────┘ └┘   └───────────────┘
src  ─────┘└────────────────┘   └───────────────┘└─────
typ  ─────┘└────────────────┘└┘ └───────────────┘└─────
doc  ─────┘                                      └─────
txt  ─────┘                                      └─────
par  ─────┘                                      └─────
pid  ─────┘                                      └─────
st   ─────────────────────────────────────────────────────
502        z.sets_of_superset ht₂ $ subset_union_right _ _,
id         └────────────────┘ └─┘   └────────────────┘
src  ─────┘└────────────────┘    └────────────────┘└─────
typ  ─────┘└────────────────┘└─┘ └────────────────┘└─────
doc  ─────┘                                        └─────
txt  ─────┘                                        └─────
par  ─────┘                                        └─────
pid  ─────┘                                        └─────
st   ───────────────────────────────────────────────────────
503        subset.trans (@le_sup_inf (set α) _ _ _ _) (union_subset (subset.refl _) hts)⟩
id         └──────────┘   └────────┘  └─┘             └──────────┘  └─────────┘    └─┘
src  ─────┘└──────────┘  └────────┘ └─┘ └─────────┘ └──────────┘ └─────────┘└──┘   └──
typ  ─────┘└──────────┘  └────────┘ └─┘└─────────┘ └──────────┘ └─────────┘└──┘└─┘└──
doc  ─────┘                             └─────────┘                         └──┘   └──
txt  ─────┘                             └─────────┘                         └──┘   └──
par  ─────┘                             └─────────┘                         └──┘   └──
pid  ─────┘                             └─────────┘                         └──┘   └┘
st   ─────────────────────────────────────────────────────────────────────────────────────
504    end,
src  ─┘
typ  ─┘
doc  ─┘
txt  ─┘
par  ─┘
pid  ─┘
st   ─┘└─┘
505    ..filter.lattice.complete_lattice }
id       └─────────────────────────────┘
src      └─────────────────────────────┘
typ      └─────────────────────────────┘
506  
507  /- the complementary version with ⨆i, f ⊓ g i does not hold! -/
508  lemma infi_sup_eq {f : filter α} {g : ι → filter α} : (⨅ x, f ⊔ g x) = f ⊔ infi g :=
id                          └────┘           └────┘                └──┘ 
src                         └────┘             └────┘                      └──┘
typ                         └────┘           └────┘                └──┘ 
doc                                                                           └──┘
509  begin
st   └─────
510    refine le_antisymm _ (le_infi $ assume i, sup_le_sup (le_refl f) $ infi_le _ _),
id            └─────────┘    └─────┘             └────────┘  └─────┘     └─────┘
src    └─────┘└─────────┘└─┘ └─────┘       └──┘└────────┘ └─────┘ └┘ └─────┘└───┘
typ    └─────┘└─────────┘└─┘ └─────┘       └──┘└────────┘ └─────┘└┘ └─────┘└───┘
doc    └─────┘           └─┘               └──┘                   └┘        └───┘
txt    └─────┘           └─┘               └──┘                   └┘        └───┘
par    └─────┘           └─┘               └──┘                   └┘        └───┘
pid                     └─┘               └──┘                   └┘        └───┘
st   ────────────────────────────────────────────────────────────────────────────────┘└─
511    rintros t ⟨h₁, h₂⟩,
src    └────────────────┘
typ    └────────────────┘
doc    └────────────────┘
txt    └────────────────┘
par    └────────────────┘
pid           └─────────┘
st   ───────────────────┘└─
512    rw [infi_sets_eq_finite] at h₂,
id         └─────────────────┘
src    └──┘└─────────────────┘└─────┘
typ    └──┘└─────────────────┘└─────┘
doc    └──┘                   └─────┘
txt    └──┘                   └─────┘
par    └──┘                   └─────┘
pid      └┘                   └────┘
st   ────────────────────────┘└────┘└─
513    simp only [mem_Union, (finset.inf_eq_infi _ _).symm] at h₂,
id                └───────┘   └────────────────┘
src    └─────────┘└───────┘└┘ └────────────────┘└───────────────┘
typ    └─────────┘└───────┘└┘ └────────────────┘└───────────────┘
doc    └─────────┘         └┘                   └───────────────┘
txt    └─────────┘         └┘                   └───────────────┘
par    └─────────┘         └┘                   └───────────────┘
pid        └──┘└┘         └┘                   └─────────┘└───┘
st   ───────────────────────────────────────────────────────────┘└─
514    rcases h₂ with ⟨s, hs⟩,
id            └┘
src    └─────┘  └───────────┘
typ    └─────┘└┘└───────────┘
doc    └─────┘  └───────────┘
txt    └─────┘  └───────────┘
par    └─────┘  └───────────┘
pid            └───────────┘
st   ───────────────────────┘└─
515    suffices : (⨅i, f ⊔ g i) ≤ f ⊔ s.inf (λi, g i.down), { exact this ⟨h₁, hs⟩ },
id                               └───┘        └───┘           └──┘  └┘  └┘
src    └─────────┘    └┘  └───┘  └─┘  └───┘    └────┘       └┘  └┘
typ    └─────────┘    └┘ └───┘  └─┘ └───┘    └────┘└──┘ └┘└┘└┘└┘
doc    └─────────┘     └┘   └───┘  └─┘           └────┘       └┘  └┘
txt    └─────────┘       └┘          └─┘           └────┘       └┘  └┘
par    └─────────┘       └┘          └─┘           └────┘       └┘  └┘
pid    └───────┘└┘       └┘          └─┘                       └┘  
st   ────────────────────────────────────────────────────┘└──┘└──────────────────┘└┘
516    refine finset.induction_on s _ _,
id            └─────────────────┘ 
src    └─────┘└─────────────────┘ └──┘
typ    └─────┘└─────────────────┘└──┘
doc    └─────┘└─────────────────┘ └──┘
txt    └─────┘                    └──┘
par    └─────┘                    └──┘
pid                              └──┘
st   ─────────────────────────────────┘└─
517    { exact le_sup_right_of_le le_top },
id             └────────────────┘ └────┘
src      └────┘└────────────────┘└────┘
typ      └────┘└────────────────┘└────┘
doc      └────┘                        
txt      └────┘                        
par      └────┘                        
pid                                   
st   ───┘└──────────────────────────────┘└┘
518    { rintros ⟨i⟩ s his ih,
src      └──────────────────┘
typ      └──────────────────┘
doc      └──────────────────┘
txt      └──────────────────┘
par      └──────────────────┘
pid             └───────────┘
st   ───────────────────────┘└─
519      rw [finset.inf_insert, sup_inf_left],
id           └───────────────┘  └──────────┘
src      └──┘└───────────────┘└┘└──────────┘
typ      └──┘└───────────────┘└┘└──────────┘
doc      └──┘                 └┘            
txt      └──┘                 └┘            
par      └──┘                 └┘            
pid        └┘                 └┘            
st   ────────────────────────┘└────────────┘└──
520      exact le_inf (infi_le _ _) ih }
id             └────┘  └─────┘      └┘
src      └────┘└────┘ └─────┘└────┘  
typ      └────┘└────┘ └─────┘└────┘└┘
doc      └────┘              └────┘  
txt      └────┘              └────┘  
par      └────┘              └────┘  
pid                         └────┘  
st   ─────────────────────────────────┘└─
521  end
st   ──┘
522  
523  lemma mem_infi_sets_finset {s : finset α} {f : α → filter β} :
id                                   └────┘           └────┘ 
src                                  └────┘             └────┘
typ                                  └────┘           └────┘ 
doc                                  └────┘
524    ∀t, t ∈ (⨅a∈s, f a) ↔ (∃p:α → set β, (∀a∈s, p a ∈ f a) ∧ (⋂a∈s, p a) ⊆ t) :=
id                      └─┘                     
src                             └─┘                               
typ                     └─┘                     
doc                                                               
525  show ∀t, t ∈ (⨅a∈s, f a) ↔ (∃p:α → set β, (∀a∈s, p a ∈ f a) ∧ (⨅a∈s, p a) ≤ t),
id                         └─┘                     
src                                └─┘                               
typ                        └─┘                     
doc                                                                  
526  begin
st   └─────
527    simp only [(finset.inf_eq_infi _ _).symm],
id                 └────────────────┘
src    └─────────┘ └────────────────┘└─────────┘
typ    └─────────┘ └────────────────┘└─────────┘
doc    └─────────┘                   └─────────┘
txt    └─────────┘                   └─────────┘
par    └─────────┘                   └─────────┘
pid        └──┘└┘                   └─────────┘
st   ──────────────────────────────────────────┘└─
528    refine finset.induction_on s _ _,
id            └─────────────────┘ 
src    └─────┘└─────────────────┘ └──┘
typ    └─────┘└─────────────────┘└──┘
doc    └─────┘└─────────────────┘ └──┘
txt    └─────┘                    └──┘
par    └─────┘                    └──┘
pid                              └──┘
st   ─────────────────────────────────┘└─
529    { simp only [finset.not_mem_empty, false_implies_iff, finset.inf_empty, top_le_iff,
id                  └──────────────────┘  └───────────────┘  └──────────────┘  └────────┘
src      └─────────┘└──────────────────┘└┘└───────────────┘└┘└──────────────┘└┘└────────┘└─
typ      └─────────┘└──────────────────┘└┘└───────────────┘└┘└──────────────┘└┘└────────┘└─
doc      └─────────┘                    └┘                 └┘                └┘          └─
txt      └─────────┘                    └┘                 └┘                └┘          └─
par      └─────────┘                    └┘                 └┘                └┘          └─
pid          └──┘└┘                    └┘                 └┘                └┘          └─
st   ───┘└─────────────────────────────────────────────────────────────────────────────────
530        imp_true_iff, mem_top_sets, true_and, exists_const],
id         └──────────┘  └──────────┘  └──────┘  └──────────┘
src  ─────┘└──────────┘└┘└──────────┘└┘└──────┘└┘└──────────┘
typ  ─────┘└──────────┘└┘└──────────┘└┘└──────┘└┘└──────────┘
doc  ─────┘            └┘            └┘        └┘            
txt  ─────┘            └┘            └┘        └┘            
par  ─────┘            └┘            └┘        └┘            
pid  ─────┘            └┘            └┘        └┘            
st   ────────────────────────────────────────────────────────┘└─
531      intros; refl },
src      └────┘  └───┘
typ      └────┘  └───┘
doc      └────┘  └───┘
txt      └────┘  └───┘
par      └────┘  └───┘
pid                  
st   ────────────────┘└┘
532    { intros a s has ih t,
src      └─────────────────┘
typ      └─────────────────┘
doc      └─────────────────┘
txt      └─────────────────┘
par      └─────────────────┘
pid            └───────────┘
st   ──────────────────────┘└─
533      simp only [ih, finset.forall_mem_insert, finset.inf_insert, mem_inf_sets,
id                  └┘  └──────────────────────┘  └───────────────┘  └──────────┘
src      └─────────┘  └┘└──────────────────────┘└┘└───────────────┘└┘└──────────┘└─
typ      └─────────┘└┘└┘└──────────────────────┘└┘└───────────────┘└┘└──────────┘└─
doc      └─────────┘  └┘                        └┘                 └┘            └─
txt      └─────────┘  └┘                        └┘                 └┘            └─
par      └─────────┘  └┘                        └┘                 └┘            └─
pid          └──┘└┘  └┘                        └┘                 └┘            └─
st   ──────────────────────────────────────────────────────────────────────────────
534        exists_prop, iff_iff_implies_and_implies, exists_imp_distrib, and_imp, and_assoc] {contextual := tt},
id         └─────────┘  └─────────────────────────┘  └────────────────┘  └─────┘  └───────┘                 └┘
src  ─────┘└─────────┘└┘└─────────────────────────┘└┘└────────────────┘└┘└─────┘└┘└───────┘└┘ └────────────┘└┘
typ  ─────┘└─────────┘└┘└─────────────────────────┘└┘└────────────────┘└┘└─────┘└┘└───────┘└┘ └────────────┘└┘
doc  ─────┘           └┘                           └┘                  └┘       └┘         └┘ └────────────┘  
txt  ─────┘           └┘                           └┘                  └┘       └┘         └┘ └────────────┘  
par  ─────┘           └┘                           └┘                  └┘       └┘         └┘ └────────────┘  
pid  ─────┘           └┘                           └┘                  └┘       └┘          └────────────┘  
st   ─────────────────────────────────────────────────────────────────────────────────────────────────────────┘└─
535      split,
src      └───┘
typ      └───┘
doc      └───┘
txt      └───┘
par      └───┘
st   ────────┘└─
536      { intros t₁ ht₁ t₂ p hp ht₂ ht,
src        └──────────────────────────┘
typ        └──────────────────────────┘
doc        └──────────────────────────┘
txt        └──────────────────────────┘
par        └──────────────────────────┘
pid              └────────────────────┘
st   ─────┘└──────────────────────────┘└─
537        existsi function.update p a t₁,
id                 └─────────────┘   └┘
src        └──────┘└─────────────┘  
typ        └──────┘└─────────────┘└┘
doc        └──────┘└─────────────┘  
txt        └──────┘                 
par        └──────┘                 
pid                                
st   ───────────────────────────────────┘└─
538        have : ∀a'∈s, function.update p a t₁ a' = p a',
id                      └─────────────┘    └┘     
src        └─────┘ └─┘  └─────────────┘       
typ        └─────┘ └─┘ └─────────────┘ └┘  
doc        └─────┘ └─┘  └─────────────┘        
txt        └─────┘ └─┘                         
par        └─────┘ └─┘                         
pid        └───┘└┘ └─┘                         
st   ───────────────────────────────────────────────────┘└─
539          from assume a' ha',
src          └───┘      └────────
typ          └───┘      └────────
doc          └───┘      └────────
txt          └───┘      └────────
par          └───┘      └────────
pid          └───┘      └────────
st   ────────────────────────────
540          have a' ≠ a, from assume h, has $ h ▸ ha',
id                                     └─┘     
src  ───────┘    └──┘ └─────┘      └──┘        └─
typ  ───────┘    └──┘└─────┘      └──┘└─┘     └─
doc  ───────┘    └──┘  └─────┘      └──┘         └─
txt  ───────┘    └──┘  └─────┘      └──┘         └─
par  ───────┘    └──┘  └─────┘      └──┘         └─
pid  ───────┘    └──┘  └─────┘      └──┘         └─
st   ───────────────────────────────────────────────────
541          function.update_noteq this _ _,
id           └───────────────────┘
src  ───────┘└───────────────────┘    └──┘
typ  ───────┘└───────────────────┘    └──┘
doc  ───────┘                         └──┘
txt  ───────┘                         └──┘
par  ───────┘                         └──┘
pid  ───────┘                         └──┘
st   ─────────────────────────────────────┘└─
542        have eq : s.inf (λj, function.update p a t₁ j) = s.inf (λj, p j) :=
id                              └─────────────┘    └┘      └───┘      
src        └────────┘       └─┘└─────────────┘     └┘ └───┘  └─┘  └────
typ        └────────┘       └─┘└─────────────┘ └┘ └┘ └───┘  └─┘ └────
doc        └────────┘       └─┘└─────────────┘     └┘ └───┘  └─┘  └────
txt        └────────┘       └─┘                    └┘        └─┘  └────
par        └────────┘       └─┘                    └┘        └─┘  └────
pid        └─────┘└─┘       └─┘                    └┘        └─┘  └───
st   ──────────────────────────────────────────────────────────────────────────
543          finset.inf_congr rfl this,
id           └──────────────┘ └─┘ └──┘
src  ───────┘└──────────────┘└─┘
typ  ───────┘└──────────────┘└─┘└──┘
doc  ───────┘                   
txt  ───────┘                   
par  ───────┘                   
pid  ───────┘                   
st   ────────────────────────────────┘└─
544        simp only [this, ht₁, hp, function.update_same, true_and, imp_true_iff, eq] {contextual := tt},
id                    └──┘  └─┘  └┘  └──────────────────┘  └──────┘  └──────────┘  └┘                 └┘
src        └─────────┘    └┘   └┘  └┘└──────────────────┘└┘└──────┘└┘└──────────┘└┘└┘└┘ └────────────┘└┘
typ        └─────────┘└──┘└┘└─┘└┘└┘└┘└──────────────────┘└┘└──────┘└┘└──────────┘└┘└┘└┘ └────────────┘└┘
doc        └─────────┘    └┘   └┘  └┘                    └┘        └┘            └┘  └┘ └────────────┘  
txt        └─────────┘    └┘   └┘  └┘                    └┘        └┘            └┘  └┘ └────────────┘  
par        └─────────┘    └┘   └┘  └┘                    └┘        └┘            └┘  └┘ └────────────┘  
pid            └──┘└┘    └┘   └┘  └┘                    └┘        └┘            └┘   └────────────┘  
st   ───────────────────────────────────────────────────────────────────────────────────────────────────┘└─
545        exact subset.trans (inter_subset_inter (subset.refl _) ht₂) ht },
id               └──────────┘  └────────────────┘  └─────────┘    └─┘  └┘
src        └────┘└──────────┘ └────────────────┘ └─────────┘└──┘   └┘  
typ        └────┘└──────────┘ └────────────────┘ └─────────┘└──┘└─┘└┘└┘
doc        └────┘                                           └──┘   └┘  
txt        └────┘                                           └──┘   └┘  
par        └────┘                                           └──┘   └┘  
pid                                                        └──┘   └┘  
st   ────────────────────────────────────────────────────────────────────┘└┘
546      assume p hpa hp ht,
src      └────────────────┘
typ      └────────────────┘
doc      └────────────────┘
txt      └────────────────┘
par      └────────────────┘
pid      └────────────────┘
st   ─────────────────────┘└─
547      exact ⟨p a, hpa, (s.inf p), ⟨⟨p, hp, le_refl _⟩, ht⟩⟩ }
id                  └─┘   └───┘         └┘  └─────┘     └┘
src      └────┘   └┘   └┘ └───┘ └─┘   └┘  └┘└─────┘└───┘  └─┘
typ      └────┘  └┘└─┘└┘ └───┘ └─┘  └┘└┘└┘└─────┘└───┘└┘└─┘
doc      └────┘   └┘   └┘ └───┘ └─┘   └┘  └┘       └───┘  └─┘
txt      └────┘   └┘   └┘       └─┘   └┘  └┘       └───┘  └─┘
par      └────┘   └┘   └┘       └─┘   └┘  └┘       └───┘  └─┘
pid              └┘   └┘       └─┘   └┘  └┘       └───┘  └┘
st   ─────────────────────────────────────────────────────────┘└─
548  end
st   ──┘
549  
550  /-! ### Eventually -/
551  
552  /-- `f.eventually p` or `∀ᶠ x in f, p x` mean that `{x | p x} ∈ f`. E.g., `∀ᶠ x in at_top, p x`
553  means that `p` holds true for sufficiently large `x`. -/
554  protected def eventually (p : α → Prop) (f : filter α) : Prop := {x | p x} ∈ f
id                                               └────┘                    
src                                               └────┘                       
typ                                              └────┘                    
555  
556  notation `∀ᶠ` binders ` in ` f `, ` r:(scoped p, filter.eventually p f) := r
id                                                    └───────────────┘
src                                                   └───────────────┘
typ                                                   └───────────────┘
doc                                                   └───────────────┘
557  
558  protected lemma eventually.and {p q : α → Prop} {f : filter α} :
id                                                       └────┘ 
src                                                       └────┘
typ                                                      └────┘ 
559    f.eventually p → f.eventually q → ∀ᶠ x in f, p x ∧ q x :=
id     └─────────┘    └─────────┘    └┘  └┘      
src     └─────────┘      └─────────┘     └┘   └┘       
typ    └─────────┘    └─────────┘    └┘  └┘      
doc     └─────────┘      └─────────┘     └┘   └┘  
560  inter_mem_sets
id   └────────────┘
src  └────────────┘
typ  └────────────┘
561  
562  @[simp]
doc    └──┘
563  lemma eventually_true (f : filter α) : ∀ᶠ x in f, true := univ_mem_sets
id                              └────┘     └┘  └┘  └──┘    └───────────┘
src                             └────┘      └┘   └┘   └──┘    └───────────┘
typ                             └────┘     └┘  └┘  └──┘    └───────────┘
doc                                         └┘   └┘  
564  
565  lemma eventually_of_forall {p : α → Prop} (f : filter α) (hp : ∀ x, p x) :
id                                                 └────┘              
src                                                 └────┘
typ                                                └────┘              
566    ∀ᶠ x in f, p x :=
id     └┘  └┘   
src    └┘   └┘  
typ    └┘  └┘   
doc    └┘   └┘  
567  univ_mem_sets' hp
id   └────────────┘ └┘
src  └────────────┘
typ  └────────────┘ └┘
568  
569  lemma eventually_false_iff_eq_bot {f : filter α} :
id                                          └────┘ 
src                                         └────┘
typ                                         └────┘ 
570    (∀ᶠ x in f, false) ↔ f = ⊥ :=
id      └┘  └┘  └───┘     
src     └┘   └┘   └───┘      
typ     └┘  └┘  └───┘     
doc     └┘   └┘  
571  empty_in_sets_eq_bot
id   └──────────────────┘
src  └──────────────────┘
typ  └──────────────────┘
572  
573  lemma eventually.mp {p q : α → Prop} {f : filter α} (hp : ∀ᶠ x in f, p x)
id                                            └────┘         └┘  └┘   
src                                            └────┘          └┘   └┘  
typ                                           └────┘         └┘  └┘   
doc                                                            └┘   └┘  
574    (hq : ∀ᶠ x in f, p x → q x) :
id           └┘  └┘       
src          └┘   └┘  
typ          └┘  └┘       
doc          └┘   └┘  
575    ∀ᶠ x in f, q x :=
id     └┘  └┘   
src    └┘   └┘  
typ    └┘  └┘   
doc    └┘   └┘  
576  mp_sets hp hq
id   └─────┘ └┘ └┘
src  └─────┘
typ  └─────┘ └┘ └┘
577  
578  lemma eventually.mono {p q : α → Prop} {f : filter α} (hp : ∀ᶠ x in f, p x)
id                                              └────┘         └┘  └┘   
src                                              └────┘          └┘   └┘  
typ                                             └────┘         └┘  └┘   
doc                                                              └┘   └┘  
579    (hq : ∀ x, p x → q x) :
id                    
typ                   
580    ∀ᶠ x in f, q x :=
id     └┘  └┘   
src    └┘   └┘  
typ    └┘  └┘   
doc    └┘   └┘  
581  hp.mp (f.eventually_of_forall hq)
id   └┘└─┘  └───────────────────┘ └┘
src    └─┘   └───────────────────┘
typ  └┘└─┘  └───────────────────┘ └┘
582  
583  @[simp]
doc    └──┘
584  lemma eventually_bot {p : α → Prop} : ∀ᶠ x in ⊥, p x := ⟨⟩
id                                        └┘  └┘       
src                                        └┘   └┘         
typ                                       └┘  └┘       
doc                                        └┘   └┘  
585  
586  @[simp]
doc    └──┘
587  lemma eventually_top {p : α → Prop} : (∀ᶠ x in ⊤, p x) ↔ (∀ x, p x) :=
id                                         └┘  └┘            
src                                         └┘   └┘       
typ                                        └┘  └┘            
doc                                         └┘   └┘  
588  iff.rfl
id   └─────┘
src  └─────┘
typ  └─────┘
589  
590  lemma eventually_sup {p : α → Prop} {f g : filter α} :
id                                             └────┘ 
src                                             └────┘
typ                                            └────┘ 
591    (∀ᶠ x in f ⊔ g, p x) ↔ (∀ᶠ x in f, p x) ∧ (∀ᶠ x in g, p x) :=
id      └┘  └┘         └┘  └┘       └┘  └┘   
src     └┘   └┘             └┘   └┘          └┘   └┘  
typ     └┘  └┘         └┘  └┘       └┘  └┘   
doc     └┘   └┘               └┘   └┘           └┘   └┘  
592  iff.rfl
id   └─────┘
src  └─────┘
typ  └─────┘
593  
594  @[simp]
doc    └──┘
595  lemma eventually_Sup {p : α → Prop} {fs : set (filter α)} :
id                                            └─┘  └────┘ 
src                                            └─┘  └────┘
typ                                           └─┘  └────┘ 
596    (∀ᶠ x in Sup fs, p x) ↔ (∀ f ∈ fs, ∀ᶠ x in f, p x) :=
id      └┘  └┘ └─┘ └┘           └┘  └┘  └┘   
src     └┘   └┘ └─┘                     └┘   └┘  
typ     └┘  └┘ └─┘ └┘           └┘  └┘  └┘   
doc     └┘   └┘ └─┘                      └┘   └┘  
597  iff.rfl
id   └─────┘
src  └─────┘
typ  └─────┘
598  
599  @[simp]
doc    └──┘
600  lemma eventually_supr {p : α → Prop} {fs : β → filter α} :
id                                                └────┘ 
src                                                 └────┘
typ                                               └────┘ 
601    (∀ᶠ x in (⨆ b, fs b), p x) ↔ (∀ b, ∀ᶠ x in fs b, p x) :=
id      └┘  └┘    └┘            └┘  └┘ └┘   
src     └┘   └┘                       └┘   └┘     
typ     └┘  └┘    └┘            └┘  └┘ └┘   
doc     └┘   └┘                        └┘   └┘     
602  mem_supr_sets
id   └───────────┘
src  └───────────┘
typ  └───────────┘
603  
604  @[simp]
doc    └──┘
605  lemma eventually_principal {a : set α} {p : α → Prop} :
id                                   └─┘        
src                                  └─┘
typ                                  └─┘        
606    (∀ᶠ x in principal a, p x) ↔ (∀ x ∈ a, p x) :=
id      └┘  └┘ └───────┘               
src     └┘   └┘ └───────┘        
typ     └┘  └┘ └───────┘               
doc     └┘   └┘ └───────┘  
607  iff.rfl
id   └─────┘
src  └─────┘
typ  └─────┘
608  
609  /-! ### Frequently -/
610  
611  /-- `f.frequently p` or `∃ᶠ x in f, p x` mean that `{x | ¬p x} ∉ f`. E.g., `∃ᶠ x in at_top, p x`
612  means that there exist arbitrarily large `x` for which `p` holds true. -/
613  protected def frequently (p : α → Prop) (f : filter α) : Prop := ¬∀ᶠ x in f, ¬p x
id                                               └────┘             └┘  └┘   
src                                               └────┘              └┘   └┘   
typ                                              └────┘             └┘  └┘   
doc                                                                    └┘   └┘  
614  
615  notation `∃ᶠ` binders ` in ` f `, ` r:(scoped p, filter.frequently p f) := r
id                                                    └───────────────┘
src                                                   └───────────────┘
typ                                                   └───────────────┘
doc                                                   └───────────────┘
616  
617  lemma eventually.frequently {f : filter α} (hf : f ≠ ⊥) {p : α → Prop} (h : ∀ᶠ x in f, p x) :
id                                    └────┘                                └┘  └┘   
src                                   └────┘                                   └┘   └┘  
typ                                   └────┘                                └┘  └┘   
doc                                                                              └┘   └┘  
618    ∃ᶠ x in f, p x :=
id     └┘  └┘   
src    └┘   └┘  
typ    └┘  └┘   
doc    └┘   └┘  
619  begin
st   └─────
620    assume h',
src    └───────┘
typ    └───────┘
doc    └───────┘
txt    └───────┘
par    └───────┘
pid    └───────┘
st   ──────────┘└─
621    have := h.and h',
id             └───┘ └┘
src    └──────┘└───┘
typ    └──────┘└───┘└┘
doc    └──────┘     
txt    └──────┘     
par    └──────┘     
pid    └───┘└─┘     
st   ─────────────────┘└─
622    simp only [and_not_self, eventually_false_iff_eq_bot] at this,
id                └──────────┘  └─────────────────────────┘
src    └─────────┘└──────────┘└┘└─────────────────────────┘└───────┘
typ    └─────────┘└──────────┘└┘└─────────────────────────┘└───────┘
doc    └─────────┘            └┘                           └───────┘
txt    └─────────┘            └┘                           └───────┘
par    └─────────┘            └┘                           └───────┘
pid        └──┘└┘            └┘                           └─────┘
st   ──────────────────────────────────────────────────────────────┘└─
623    exact hf this
id           └┘ └──┘
src    └────┘      
typ    └────┘└┘└──┘
doc    └────┘      
txt    └────┘      
par    └────┘      
pid               
st   ───────────────┘
624  end
st   └─┘
625  
626  lemma frequently.mp {p q : α → Prop} {f : filter α} (h : ∃ᶠ x in f, p x)
id                                            └────┘        └┘  └┘   
src                                            └────┘         └┘   └┘  
typ                                           └────┘        └┘  └┘   
doc                                                           └┘   └┘  
627    (hpq : ∀ᶠ x in f, p x → q x) :
id            └┘  └┘       
src           └┘   └┘  
typ           └┘  └┘       
doc           └┘   └┘  
628    ∃ᶠ x in f, q x :=
id     └┘  └┘   
src    └┘   └┘  
typ    └┘  └┘   
doc    └┘   └┘  
629  mt (λ hq, hq.mp $ hpq.mono $ λ x, mt) h
id   └┘    └┘  └┘└─┘   └─┘└───┘       └┘  
src  └┘          └─┘      └───┘        └┘
typ  └┘    └┘  └┘└─┘   └─┘└───┘       └┘  
630  
631  lemma frequently.mono {p q : α → Prop} {f : filter α} (h : ∃ᶠ x in f, p x)
id                                              └────┘        └┘  └┘   
src                                              └────┘         └┘   └┘  
typ                                             └────┘        └┘  └┘   
doc                                                             └┘   └┘  
632    (hpq : ∀ x, p x → q x) :
id                     
typ                    
633    ∃ᶠ x in f, q x :=
id     └┘  └┘   
src    └┘   └┘  
typ    └┘  └┘   
doc    └┘   └┘  
634  h.mp (f.eventually_of_forall hpq)
id   └─┘  └───────────────────┘ └─┘
src   └─┘   └───────────────────┘
typ  └─┘  └───────────────────┘ └─┘
635  
636  lemma frequently.and_eventually {p q : α → Prop} {f : filter α}
id                                                        └────┘ 
src                                                        └────┘
typ                                                       └────┘ 
637    (hp : ∃ᶠ x in f, p x) (hq : ∀ᶠ x in f, q x) :
id           └┘  └┘           └┘  └┘   
src          └┘   └┘              └┘   └┘  
typ          └┘  └┘           └┘  └┘   
doc          └┘   └┘              └┘   └┘  
638    ∃ᶠ x in f, p x ∧ q x :=
id     └┘  └┘      
src    └┘   └┘       
typ    └┘  └┘      
doc    └┘   └┘  
639  begin
st   └─────
640    refine mt (λ h, hq.mp $ h.mono _) hp,
id            └┘       └───┘    └───┘    └┘
src    └─────┘└┘  └──┘└───┘  └───┘└──┘
typ    └─────┘└┘  └──┘└───┘  └───┘└──┘└┘
doc    └─────┘    └──┘            └──┘
txt    └─────┘    └──┘            └──┘
par    └─────┘    └──┘            └──┘
pid              └──┘            └──┘
st   ─────────────────────────────────────┘└─
641    assume x hpq hq hp,
src    └────────────────┘
typ    └────────────────┘
doc    └────────────────┘
txt    └────────────────┘
par    └────────────────┘
pid    └────────────────┘
st   ───────────────────┘└─
642    exact hpq ⟨hp, hq⟩
id           └─┘  └┘  └┘
src    └────┘      └┘  └┘
typ    └────┘└─┘ └┘└┘└┘└┘
doc    └────┘      └┘  └┘
txt    └────┘      └┘  └┘
par    └────┘      └┘  └┘
pid               └┘  
st   ────────────────────┘
643  end
st   └─┘
644  
645  lemma frequently.exists {p : α → Prop} {f : filter α} (hp : ∃ᶠ x in f, p x) : ∃ x, p x :=
id                                              └────┘         └┘  └┘          
src                                              └────┘          └┘   └┘            
typ                                             └────┘         └┘  └┘          
doc                                                              └┘   └┘  
646  begin
st   └─────
647    by_contradiction H,
src    └────────────────┘
typ    └────────────────┘
doc    └────────────────┘
txt    └────────────────┘
par    └────────────────┘
pid                    └┘
st   ───────────────────┘└─
648    replace H : ∀ᶠ x in f, ¬ p x, from f.eventually_of_forall (not_exists.1 H),
id                 └┘   └┘             └────────────────────┘  └────────┘   
src    └──────────┘└┘└─┘└┘      └───┘└────────────────────┘ └────────┘└─┘ 
typ    └──────────┘└┘└─┘└┘    └───┘└────────────────────┘ └────────┘└─┘
doc    └──────────┘└┘└─┘└┘      └───┘                                 └─┘ 
txt    └──────────┘  └─┘         └───┘                                 └─┘ 
par    └──────────┘  └─┘         └───┘                                 └─┘ 
pid           └┘└─┘  └─┘         └───┘                                 └─┘ 
st   ─────────────────────────────┘└────────────────────────────────────────────┘└─
649    exact hp H
id           └┘ 
src    └────┘   
typ    └────┘└┘
doc    └────┘   
txt    └────┘   
par    └────┘   
pid            
st   ────────────┘
650  end
st   └─┘
651  
652  lemma eventually.exists {p : α → Prop} {f : filter α} (hp : ∀ᶠ x in f, p x) (hf : f ≠ ⊥) :
id                                              └────┘         └┘  └┘             
src                                              └────┘          └┘   └┘                 
typ                                             └────┘         └┘  └┘             
doc                                                              └┘   └┘  
653    ∃ x, p x :=
id        
src      
typ       
654  (hp.frequently hf).exists
id    └┘└─────────┘ └┘ └────┘
src     └─────────┘    └────┘
typ   └┘└─────────┘ └┘ └────┘
655  
656  lemma frequently_iff_forall_eventually_exists_and {p : α → Prop} {f : filter α} :
id                                                                        └────┘ 
src                                                                        └────┘
typ                                                                       └────┘ 
657    (∃ᶠ x in f, p x) ↔ ∀ {q : α → Prop}, (∀ᶠ x in f, q x) → ∃ x, p x ∧ q x :=
id      └┘  └┘                       └┘  └┘             
src     └┘   └┘                            └┘   └┘                 
typ     └┘  └┘                       └┘  └┘             
doc     └┘   └┘                             └┘   └┘  
658  ⟨assume hp q hq, (hp.and_eventually hq).exists,
id           └┘  └┘   └┘└─────────────┘ └┘ └────┘
src                      └─────────────┘    └────┘
typ          └┘  └┘   └┘└─────────────┘ └┘ └────┘
659    assume H hp, by simpa only [and_not_self, exists_false] using H hp⟩
id             └┘                 └──────────┘  └──────────┘         └┘
src                    └──────────┘└──────────┘└┘└──────────┘└──────┘ 
typ            └┘     └──────────┘└──────────┘└┘└──────────┘└──────┘└┘
doc                    └──────────┘            └┘            └──────┘ 
txt                    └──────────┘            └┘            └──────┘ 
par                    └──────────┘            └┘            └──────┘ 
pid                         └──┘└┘            └┘            └────┘ 
st                    └─────────────────────────────────────────────────┘
660  
661  @[simp] lemma not_eventually {p : α → Prop} {f : filter α} :
id                                                   └────┘ 
src                                                   └────┘
typ                                                  └────┘ 
doc    └──┘
662    (¬ ∀ᶠ x in f, p x) ↔ (∃ᶠ x in f, ¬ p x) :=
id       └┘  └┘       └┘  └┘    
src      └┘   └┘          └┘   └┘   
typ      └┘  └┘       └┘  └┘    
doc       └┘   └┘           └┘   └┘  
663  by simp [filter.frequently]
id            └───────────────┘
src     └────┘└───────────────┘└─
typ     └────┘└───────────────┘└─
doc     └────┘└───────────────┘└─
txt     └────┘                 └─
par     └────┘                 └─
pid                          
st     └─────────────────────────
664  
src  
typ  
doc  
txt  
par  
pid  
st   
665  @[simp] lemma not_frequently {p : α → Prop} {f : filter α} :
id                                                   └────┘ 
src                                                   └────┘
typ                                                  └────┘ 
doc    └──┘
666    (¬ ∃ᶠ x in f, p x) ↔ (∀ᶠ x in f, ¬ p x) :=
id       └┘  └┘       └┘  └┘    
src      └┘   └┘          └┘   └┘   
typ      └┘  └┘       └┘  └┘    
doc       └┘   └┘           └┘   └┘  
667  by simp only [filter.frequently, not_not]
id                 └───────────────┘  └─────┘
src     └─────────┘└───────────────┘└┘└─────┘└─
typ     └─────────┘└───────────────┘└┘└─────┘└─
doc     └─────────┘└───────────────┘└┘       └─
txt     └─────────┘                 └┘       └─
par     └─────────┘                 └┘       └─
pid         └──┘└┘                 └┘       
st     └───────────────────────────────────────
668  
src  
typ  
doc  
txt  
par  
pid  
st   
669  lemma frequently_true_iff_ne_bot (f : filter α) : (∃ᶠ x in f, true) ↔ f ≠ ⊥ :=
id                                         └────┘      └┘  └┘  └──┘     
src                                        └────┘       └┘   └┘   └──┘      
typ                                        └────┘      └┘  └┘  └──┘     
doc                                                     └┘   └┘  
670  by simp [filter.frequently, -not_eventually, eventually_false_iff_eq_bot]
id            └───────────────┘                   └─────────────────────────┘
src     └────┘└───────────────┘└─────────────────┘└─────────────────────────┘└─
typ     └────┘└───────────────┘└─────────────────┘└─────────────────────────┘└─
doc     └────┘└───────────────┘└─────────────────┘                           └─
txt     └────┘                 └─────────────────┘                           └─
par     └────┘                 └─────────────────┘                           └─
pid                          └─────────────────┘                           
st     └───────────────────────────────────────────────────────────────────────
671  
src  
typ  
doc  
txt  
par  
pid  
st   
672  lemma frequently_false (f : filter α) : ¬ ∃ᶠ x in f, false := by simp
id                               └────┘      └┘  └┘  └───┘
src                              └────┘       └┘   └┘   └───┘       └────
typ                              └────┘      └┘  └┘  └───┘       └────
doc                                            └┘   └┘               └────
txt                                                                   └────
par                                                                   └────
pid                                                                       
st                                                                   └─────
673  
src  
typ  
doc  
txt  
par  
pid  
st   
674  lemma frequently_bot {p : α → Prop} : ¬ ∃ᶠ x in ⊥, p x := by simp
id                                         └┘  └┘   
src                                         └┘   └┘            └────
typ                                        └┘  └┘          └────
doc                                          └┘   └┘             └────
txt                                                               └────
par                                                               └────
pid                                                                   
st                                                               └─────
675  
src  
typ  
doc  
txt  
par  
pid  
st   
676  @[simp]
doc    └──┘
677  lemma frequently_top {p : α → Prop} : (∃ᶠ x in ⊤, p x) ↔ (∃ x, p x) :=
id                                         └┘  └┘          
src                                         └┘   └┘           
typ                                        └┘  └┘          
doc                                         └┘   └┘  
678  by simp [filter.frequently]
id            └───────────────┘
src     └────┘└───────────────┘└─
typ     └────┘└───────────────┘└─
doc     └────┘└───────────────┘└─
txt     └────┘                 └─
par     └────┘                 └─
pid                          
st     └─────────────────────────
679  
src  
typ  
doc  
txt  
par  
pid  
st   
680  @[simp]
doc    └──┘
681  lemma frequently_principal {a : set α} {p : α → Prop} :
id                                   └─┘        
src                                  └─┘
typ                                  └─┘        
682    (∃ᶠ x in principal a, p x) ↔ (∃ x ∈ a, p x) :=
id      └┘  └┘ └───────┘             
src     └┘   └┘ └───────┘                
typ     └┘  └┘ └───────┘             
doc     └┘   └┘ └───────┘  
683  by simp [filter.frequently, not_forall]
id            └───────────────┘  └────────┘
src     └────┘└───────────────┘└┘└────────┘└─
typ     └────┘└───────────────┘└┘└────────┘└─
doc     └────┘└───────────────┘└┘          └─
txt     └────┘                 └┘          └─
par     └────┘                 └┘          └─
pid                          └┘          
st     └─────────────────────────────────────
684  
src  
typ  
doc  
txt  
par  
pid  
st   
685  lemma frequently_sup {p : α → Prop} {f g : filter α} :
id                                             └────┘ 
src                                             └────┘
typ                                            └────┘ 
686    (∃ᶠ x in f ⊔ g, p x) ↔ (∃ᶠ x in f, p x) ∨ (∃ᶠ x in g, p x) :=
id      └┘  └┘         └┘  └┘       └┘  └┘   
src     └┘   └┘             └┘   └┘          └┘   └┘  
typ     └┘  └┘         └┘  └┘       └┘  └┘   
doc     └┘   └┘               └┘   └┘           └┘   └┘  
687  by simp only [filter.frequently, eventually_sup, not_and_distrib]
id                 └───────────────┘  └────────────┘  └─────────────┘
src     └─────────┘└───────────────┘└┘└────────────┘└┘└─────────────┘└─
typ     └─────────┘└───────────────┘└┘└────────────┘└┘└─────────────┘└─
doc     └─────────┘└───────────────┘└┘              └┘               └─
txt     └─────────┘                 └┘              └┘               └─
par     └─────────┘                 └┘              └┘               └─
pid         └──┘└┘                 └┘              └┘               
st     └───────────────────────────────────────────────────────────────
688  
src  
typ  
doc  
txt  
par  
pid  
st   
689  @[simp]
doc    └──┘
690  lemma frequently_Sup {p : α → Prop} {fs : set (filter α)} :
id                                            └─┘  └────┘ 
src                                            └─┘  └────┘
typ                                           └─┘  └────┘ 
691    (∃ᶠ x in Sup fs, p x) ↔ (∃ f ∈ fs, ∃ᶠ x in f, p x) :=
id      └┘  └┘ └─┘ └┘          └┘ └┘  └┘   
src     └┘   └┘ └─┘                   └┘   └┘  
typ     └┘  └┘ └─┘ └┘          └┘ └┘  └┘   
doc     └┘   └┘ └─┘                      └┘   └┘  
692  by simp [filter.frequently, -not_eventually, not_forall]
id            └───────────────┘                   └────────┘
src     └────┘└───────────────┘└─────────────────┘└────────┘└─
typ     └────┘└───────────────┘└─────────────────┘└────────┘└─
doc     └────┘└───────────────┘└─────────────────┘          └─
txt     └────┘                 └─────────────────┘          └─
par     └────┘                 └─────────────────┘          └─
pid                          └─────────────────┘          
st     └──────────────────────────────────────────────────────
693  
src  
typ  
doc  
txt  
par  
pid  
st   
694  @[simp]
doc    └──┘
695  lemma frequently_supr {p : α → Prop} {fs : β → filter α} :
id                                                └────┘ 
src                                                 └────┘
typ                                               └────┘ 
696    (∃ᶠ x in (⨆ b, fs b), p x) ↔ (∃ b, ∃ᶠ x in fs b, p x) :=
id      └┘  └┘    └┘          └┘  └┘ └┘   
src     └┘   └┘                     └┘   └┘     
typ     └┘  └┘    └┘          └┘  └┘ └┘   
doc     └┘   └┘                        └┘   └┘     
697  by simp [filter.frequently, -not_eventually, not_forall]
id            └───────────────┘                   └────────┘
src     └────┘└───────────────┘└─────────────────┘└────────┘└─
typ     └────┘└───────────────┘└─────────────────┘└────────┘└─
doc     └────┘└───────────────┘└─────────────────┘          └─
txt     └────┘                 └─────────────────┘          └─
par     └────┘                 └─────────────────┘          └─
pid                          └─────────────────┘          
st     └──────────────────────────────────────────────────────
698  
src  
typ  
doc  
txt  
par  
pid  
st   
699  /- principal equations -/
src  ──────────────────────────
typ  ──────────────────────────
doc  ──────────────────────────
txt  ──────────────────────────
par  ──────────────────────────
pid  ──────────────────────────
st   ──────────────────────────
700  
src  
typ  
doc  
txt  
par  
pid  
st   
701  @[simp] lemma inf_principal {s t : set α} : principal s ⊓ principal t = principal (s ∩ t) :=
id                                      └─┘     └───────┘   └───────┘   └───────┘    
src                                     └─┘      └───────┘    └───────┘    └───────┘    
typ                                     └─┘     └───────┘   └───────┘   └───────┘    
doc    └──┘                                      └───────┘     └───────┘     └───────┘
702  le_antisymm
id   └─────────┘
src  └─────────┘
typ  └─────────┘
703    (by simp; exact ⟨s, subset.refl s, t, subset.refl t, by simp⟩)
id                                          └─────────┘ 
src        └──┘  └────┘  └┘            └┘ └┘└─────────┘ └┘  └──┘
typ        └──┘  └────┘  └┘           └┘ └┘└─────────┘└┘  └──┘
doc        └──┘  └────┘  └┘            └┘ └┘            └┘  └──┘
txt        └──┘  └────┘  └┘            └┘ └┘            └┘  └──┘
par        └──┘  └────┘  └┘            └┘ └┘            └┘  └──┘
pid                     └┘            └┘ └┘            └┘  └────┘
st        └──────────────────────────────────────────────────┘└───┘
704    (by simp [le_inf_iff, inter_subset_left, inter_subset_right])
id               └────────┘  └───────────────┘  └────────────────┘
src        └────┘└────────┘└┘└───────────────┘└┘└────────────────┘
typ        └────┘└────────┘└┘└───────────────┘└┘└────────────────┘
doc        └────┘          └┘                 └┘                  
txt        └────┘          └┘                 └┘                  
par        └────┘          └┘                 └┘                  
pid                      └┘                 └┘                  
st        └───────────────────────────────────────────────────────┘
705  
706  @[simp] lemma sup_principal {s t : set α} : principal s ⊔ principal t = principal (s ∪ t) :=
id                                      └─┘     └───────┘   └───────┘   └───────┘    
src                                     └─┘      └───────┘    └───────┘    └───────┘    
typ                                     └─┘     └───────┘   └───────┘   └───────┘    
doc    └──┘                                      └───────┘     └───────┘     └───────┘
707  filter_eq $ set.ext $
id   └───────┘   └─────┘
src  └───────┘   └─────┘
typ  └───────┘   └─────┘
708    by simp only [union_subset_iff, union_subset_iff, mem_sup_sets, forall_const, iff_self, mem_principal_sets]
id                   └──────────────┘  └──────────────┘  └──────────┘  └──────────┘  └──────┘  └────────────────┘
src       └─────────┘└──────────────┘└┘└──────────────┘└┘└──────────┘└┘└──────────┘└┘└──────┘└┘└────────────────┘└─
typ       └─────────┘└──────────────┘└┘└──────────────┘└┘└──────────┘└┘└──────────┘└┘└──────┘└┘└────────────────┘└─
doc       └─────────┘                └┘                └┘            └┘            └┘        └┘                  └─
txt       └─────────┘                └┘                └┘            └┘            └┘        └┘                  └─
par       └─────────┘                └┘                └┘            └┘            └┘        └┘                  └─
pid           └──┘└┘                └┘                └┘            └┘            └┘        └┘                  
st       └─────────────────────────────────────────────────────────────────────────────────────────────────────────
709  
src  
typ  
doc  
txt  
par  
pid  
st   
710  @[simp] lemma supr_principal {ι : Sort w} {s : ι → set α} : (⨆x, principal (s x)) = principal (⋃i, s i) :=
id                                                     └─┘       └───────┘       └───────┘    
src                                                     └─┘         └───────┘         └───────┘   
typ                                                    └─┘       └───────┘       └───────┘    
doc    └──┘                                                         └───────┘          └───────┘   
711  filter_eq $ set.ext $ assume x, by simp only [supr_sets_eq, mem_principal_sets, mem_Inter];
id   └───────┘   └─────┘                          └──────────┘  └────────────────┘  └───────┘
src  └───────┘   └─────┘                └─────────┘└──────────┘└┘└────────────────┘└┘└───────┘
typ  └───────┘   └─────┘               └─────────┘└──────────┘└┘└────────────────┘└┘└───────┘
doc                                     └─────────┘            └┘                  └┘         
txt                                     └─────────┘            └┘                  └┘         
par                                     └─────────┘            └┘                  └┘         
pid                                         └──┘└┘            └┘                  └┘         
st                                     └─────────────────────────────────────────────────────────
712  exact (@supr_le_iff (set α) _ _ _ _).symm
id           └─────────┘  └─┘ 
src  └────┘  └─────────┘ └─┘ └───────────────
typ  └────┘  └─────────┘ └─┘└───────────────
doc  └────┘                  └───────────────
txt  └────┘                  └───────────────
par  └────┘                  └───────────────
pid                         └────────────┘└─
st   ──────────────────────────────────────────
713  
src  
typ  
doc  
txt  
par  
pid  
st   
714  lemma principal_univ : principal (univ : set α) = ⊤ :=
id                          └───────┘  └──┘   └─┘    
src                         └───────┘  └──┘   └─┘     
typ                         └───────┘  └──┘   └─┘    
doc                         └───────┘
715  top_unique $ by simp only [le_principal_iff, mem_top_sets, eq_self_iff_true]
id   └────────┘                 └──────────────┘  └──────────┘  └──────────────┘
src  └────────┘      └─────────┘└──────────────┘└┘└──────────┘└┘└──────────────┘└─
typ  └────────┘      └─────────┘└──────────────┘└┘└──────────┘└┘└──────────────┘└─
doc                  └─────────┘                └┘            └┘                └─
txt                  └─────────┘                └┘            └┘                └─
par                  └─────────┘                └┘            └┘                └─
pid                      └──┘└┘                └┘            └┘                
st                  └─────────────────────────────────────────────────────────────
716  
src  
typ  
doc  
txt  
par  
pid  
st   
717  lemma principal_empty : principal (∅ : set α) = ⊥ :=
id                           └───────┘     └─┘    
src                          └───────┘     └─┘     
typ                          └───────┘     └─┘    
doc                          └───────┘
718  bot_unique $ assume s _, empty_subset _
id   └────────┘             └──────────┘
src  └────────┘               └──────────┘
typ  └────────┘             └──────────┘
719  
720  @[simp] lemma principal_eq_bot_iff {s : set α} : principal s = ⊥ ↔ s = ∅ :=
id                                           └─┘     └───────┘       
src                                          └─┘      └───────┘         
typ                                          └─┘     └───────┘       
doc    └──┘                                           └───────┘
721  empty_in_sets_eq_bot.symm.trans $ mem_principal_sets.trans subset_empty_iff
id   └──────────────────┘└───┘└────┘   └────────────────┘└────┘ └──────────────┘
src  └──────────────────┘└───┘└────┘   └────────────────┘└────┘ └──────────────┘
typ  └──────────────────┘└───┘└────┘   └────────────────┘└────┘ └──────────────┘
722  
723  @[simp] lemma principal_ne_bot_iff {s : set α} : principal s ≠ ⊥ ↔ s.nonempty :=
id                                           └─┘     └───────┘     └───────┘
src                                          └─┘      └───────┘       └───────┘
typ                                          └─┘     └───────┘     └───────┘
doc    └──┘                                           └───────┘          └───────┘
724  (not_congr principal_eq_bot_iff).trans ne_empty_iff_nonempty
id    └───────┘ └──────────────────┘ └───┘  └───────────────────┘
src   └───────┘ └──────────────────┘ └───┘  └───────────────────┘
typ   └───────┘ └──────────────────┘ └───┘  └───────────────────┘
725  
726  lemma inf_principal_eq_bot {f : filter α} {s : set α} (hs : -s ∈ f) : f ⊓ principal s = ⊥ :=
id                                   └────┘        └─┘                 └───────┘   
src                                  └────┘         └─┘                     └───────┘    
typ                                  └────┘        └─┘                 └───────┘   
doc                                                                            └───────┘
727  empty_in_sets_eq_bot.mp ⟨_, hs, s, mem_principal_self s, assume x ⟨h₁, h₂⟩, h₁ h₂⟩
id   └──────────────────┘└─┘     └┘    └────────────────┘           └┘  └┘
src  └──────────────────┘└─┘            └────────────────┘
typ  └──────────────────┘└─┘     └┘    └────────────────┘           └┘  └┘
728  
729  theorem mem_inf_principal (f : filter α) (s t : set α) :
id                                  └────┘          └─┘ 
src                                 └────┘           └─┘
typ                                 └────┘          └─┘ 
730    s ∈ f ⊓ principal t ↔ { x | x ∈ t → x ∈ s } ∈ f :=
id         └───────┘                  
src          └───────┘                       
typ        └───────┘                  
doc            └───────┘
731  begin
st   └─────
732    simp only [mem_inf_sets, mem_principal_sets, exists_prop], split,
id                └──────────┘  └────────────────┘  └─────────┘
src    └─────────┘└──────────┘└┘└────────────────┘└┘└─────────┘  └───┘
typ    └─────────┘└──────────┘└┘└────────────────┘└┘└─────────┘  └───┘
doc    └─────────┘            └┘                  └┘             └───┘
txt    └─────────┘            └┘                  └┘             └───┘
par    └─────────┘            └┘                  └┘             └───┘
pid        └──┘└┘            └┘                  └┘           
st   ──────────────────────────────────────────────────────────┘└─────┘└─
733    { rintros ⟨u, ul, v, tsubv, uvinter⟩,
src      └────────────────────────────────┘
typ      └────────────────────────────────┘
doc      └────────────────────────────────┘
txt      └────────────────────────────────┘
par      └────────────────────────────────┘
pid             └─────────────────────────┘
st   ───┘└────────────────────────────────┘└─
734      apply filter.mem_sets_of_superset ul,
id             └─────────────────────────┘ └┘
src      └────┘└─────────────────────────┘
typ      └────┘└─────────────────────────┘└┘
doc      └────┘                           
txt      └────┘                           
par      └────┘                           
pid                                      
st   ───────────────────────────────────────┘└─
735      intros x xu xt, exact uvinter ⟨xu, tsubv xt⟩ },
id                             └─────┘  └┘  └───┘ └┘
src      └────────────┘  └────┘          └┘       └┘
typ      └────────────┘  └────┘└─────┘ └┘└┘└───┘└┘└┘
doc      └────────────┘  └────┘          └┘       └┘
txt      └────────────┘  └────┘          └┘       └┘
par      └────────────┘  └────┘          └┘       └┘
pid            └──────┘                 └┘       
st   ─────────────────┘└─────────────────────────────┘└┘
736    intro h, refine ⟨_, h, t, set.subset.refl t, _⟩,
id                              └─────────────┘ 
src    └─────┘  └─────┘ └─┘ └┘ └┘└─────────────┘ └──┘
typ    └─────┘  └─────┘ └─┘└┘ └┘└─────────────┘└──┘
doc    └─────┘  └─────┘ └─┘ └┘ └┘                └──┘
txt    └─────┘  └─────┘ └─┘ └┘ └┘                └──┘
par    └─────┘  └─────┘ └─┘ └┘ └┘                └──┘
pid         └┘         └─┘ └┘ └┘                └──┘
st   ────────┘└──────────────────────────────────────┘└─
737    rintros x ⟨hx, xt⟩,
src    └────────────────┘
typ    └────────────────┘
doc    └────────────────┘
txt    └────────────────┘
par    └────────────────┘
pid           └─────────┘
st   ───────────────────┘└─
738    exact hx xt
id           └┘ └┘
src    └────┘    
typ    └────┘└┘└┘
doc    └────┘    
txt    └────┘    
par    └────┘    
pid             
st   ─────────────┘
739  end
st   └─┘
740  
741  @[simp] lemma infi_principal_finset {ι : Type w} (s : finset ι) (f : ι → set α) :
id                                                         └────┘           └─┘ 
src                                                        └────┘             └─┘
typ                                                        └────┘           └─┘ 
doc    └──┘                                                └────┘
742    (⨅i∈s, principal (f i)) = principal (⋂i∈s, f i) :=
id        └───────┘       └───────┘     
src         └───────┘         └───────┘     
typ       └───────┘       └───────┘     
doc         └───────┘          └───────┘     
743  begin
st   └─────
744    ext t,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
pid       └┘
st   ──────┘└─
745    simp [mem_infi_sets_finset],
id           └──────────────────┘
src    └────┘└──────────────────┘
typ    └────┘└──────────────────┘
doc    └────┘                    
txt    └────┘                    
par    └────┘                    
pid                            
st   ────────────────────────────┘└─
746    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
747    { rintros ⟨p, hp, ht⟩,
src      └─────────────────┘
typ      └─────────────────┘
doc      └─────────────────┘
txt      └─────────────────┘
par      └─────────────────┘
pid             └──────────┘
st   ───┘└─────────────────┘└─
748      calc (⋂ (i : ι) (H : i ∈ s), f i) ≤ (⋂ (i : ι) (H : i ∈ s), p i) :
id       └──┘                                                  
src      └──┘                     
typ      └──┘                                                  
doc      └──┘                      
st   ───────────────────────────────────────────────────────────────────────
749        infi_le_infi (λi, infi_le_infi (λhi, mem_principal_sets.1 (hp i hi)))
id                          └──────────┘   └┘  └────────────────┘   └┘
src                          └──────────┘       └────────────────┘
typ                         └──────────┘   └┘  └────────────────┘   └┘
st   ────────────────────────────────────────────────────────────────────────────
750      ... ≤ t : ht },
id                └┘
typ               └┘
st   ───────────────┘└─┘
751    { assume h,
src      └──────┘
typ      └──────┘
doc      └──────┘
txt      └──────┘
par      └──────┘
pid      └──────┘
st   ───────────┘└─
752      exact ⟨f, λi hi, subset.refl _, h⟩ }
id                       └─────────┘    
src      └────┘  └┘ └────┘└─────────┘└──┘ └┘
typ      └────┘ └┘ └────┘└─────────┘└──┘└┘
doc      └────┘  └┘ └────┘           └──┘ └┘
txt      └────┘  └┘ └────┘           └──┘ └┘
par      └────┘  └┘ └────┘           └──┘ └┘
pid             └┘ └────┘           └──┘ 
st   ──────────────────────────────────────┘└─
753  end
st   ──┘
754  
755  @[simp] lemma infi_principal_fintype {ι : Type w} [fintype ι] (f : ι → set α) :
id                                                      └─────┘           └─┘ 
src                                                     └─────┘             └─┘
typ                                                     └─────┘           └─┘ 
doc    └──┘                                             └─────┘
756    (⨅i, principal (f i)) = principal (⋂i, f i) :=
id       └───────┘       └───────┘    
src       └───────┘         └───────┘   
typ      └───────┘       └───────┘    
doc       └───────┘          └───────┘   
757  by simpa using infi_principal_finset finset.univ f
id                  └───────────────────┘ └─────────┘ 
src     └──────────┘└───────────────────┘└─────────┘ 
typ     └──────────┘└───────────────────┘└─────────┘
doc     └──────────┘                     └─────────┘ 
txt     └──────────┘                                 
par     └──────────┘                                 
pid          └────┘                                 
st     └────────────────────────────────────────────────
758  
src  
typ  
doc  
txt  
par  
pid  
st   
759  end lattice
760  
761  section map
762  
763  /-- The forward map of a filter -/
764  def map (m : α → β) (f : filter α) : filter β :=
id                          └────┘     └────┘ 
src                           └────┘      └────┘
typ                         └────┘     └────┘ 
765  { sets             := preimage m ⁻¹' f.sets,
id                         └──────┘  └─┘ └───┘
src                        └──────┘   └─┘  └───┘
typ                        └──────┘  └─┘ └───┘
doc                        └──────┘   └─┘
766    univ_sets        := univ_mem_sets,
id                         └───────────┘
src                        └───────────┘
typ                        └───────────┘
767    sets_of_superset := assume s t hs st, mem_sets_of_superset hs $ preimage_mono st,
id                                  └┘ └┘  └──────────────────┘ └┘   └───────────┘ └┘
src                                          └──────────────────┘      └───────────┘
typ                                 └┘ └┘  └──────────────────┘ └┘   └───────────┘ └┘
768    inter_sets       := assume s t hs ht, inter_mem_sets hs ht }
id                                  └┘ └┘  └────────────┘ └┘ └┘
src                                          └────────────┘
typ                                 └┘ └┘  └────────────┘ └┘ └┘
769  
770  @[simp] lemma map_principal {s : set α} {f : α → β} :
id                                    └─┘           
src                                   └─┘
typ                                   └─┘           
doc    └──┘
771    map f (principal s) = principal (set.image f s) :=
id     └─┘   └───────┘    └───────┘  └───────┘  
src    └─┘    └───────┘     └───────┘  └───────┘
typ    └─┘   └───────┘    └───────┘  └───────┘  
doc    └─┘    └───────┘      └───────┘
772  filter_eq $ set.ext $ assume a, image_subset_iff.symm
id   └───────┘   └─────┘            └──────────────┘└───┘
src  └───────┘   └─────┘             └──────────────┘└───┘
typ  └───────┘   └─────┘            └──────────────┘└───┘
doc                                  └──────────────┘
773  
774  variables {f : filter α} {m : α → β} {m' : β → γ} {s : set α} {t : set β}
id                  └────┘                                  └─┘         └─┘
src                 └────┘                                  └─┘         └─┘
typ                 └────┘                                  └─┘         └─┘
775  
776  @[simp] lemma mem_map : t ∈ map m f ↔ {x | m x ∈ t} ∈ f := iff.rfl
id                             └─┘                 └─────┘
src                             └─┘                        └─────┘
typ                            └─┘                 └─────┘
doc    └──┘                      └─┘
777  
778  lemma image_mem_map (hs : s ∈ f) : m '' s ∈ map m f :=
id                                    └┘   └─┘  
src                                      └┘    └─┘
typ                                   └┘   └─┘  
doc                                              └─┘
779  f.sets_of_superset hs $ subset_preimage_image m s
id   └───────────────┘ └┘   └───────────────────┘  
src   └───────────────┘      └───────────────────┘
typ  └───────────────┘ └┘   └───────────────────┘  
780  
781  lemma range_mem_map : range m ∈ map m f :=
id                         └───┘   └─┘  
src                        └───┘    └─┘
typ                        └───┘   └─┘  
doc                        └───┘     └─┘
782  by rw ←image_univ; exact image_mem_map univ_mem_sets
id          └────────┘        └───────────┘ └───────────┘
src     └──┘└────────┘  └────┘└───────────┘└───────────┘
typ     └──┘└────────┘  └────┘└───────────┘└───────────┘
doc     └──┘            └────┘                          
txt     └──┘            └────┘                          
par     └──┘            └────┘                          
pid       └┘                                           
st     └──────────────────────────────────────────────────
783  
src  
typ  
doc  
txt  
par  
pid  
st   
784  lemma mem_map_sets_iff : t ∈ map m f ↔ (∃s∈f, m '' s ⊆ t) :=
id                              └─┘        └┘   
src                              └─┘             └┘   
typ                             └─┘        └┘   
doc                               └─┘
785  iff.intro
id   └───────┘
src  └───────┘
typ  └───────┘
786    (assume ht, ⟨set.preimage m t, ht, image_preimage_subset _ _⟩)
id             └┘   └──────────┘    └┘  └───────────────────┘
src                 └──────────┘          └───────────────────┘
typ            └┘   └──────────┘    └┘  └───────────────────┘
doc                 └──────────┘
787    (assume ⟨s, hs, ht⟩, mem_sets_of_superset (image_mem_map hs) ht)
id                └┘  └┘   └──────────────────┘  └───────────┘
src                         └──────────────────┘  └───────────┘
typ               └┘  └┘   └──────────────────┘  └───────────┘
788  
789  @[simp] lemma map_id : filter.map id f = f :=
id                          └────────┘ └┘   
src                         └────────┘ └┘   
typ                         └────────┘ └┘   
doc    └──┘                 └────────┘
790  filter_eq $ rfl
id   └───────┘   └─┘
src  └───────┘   └─┘
typ  └───────┘   └─┘
791  
792  @[simp] lemma map_compose : filter.map m' ∘ filter.map m = filter.map (m' ∘ m) :=
id                               └────────┘ └┘  └────────┘   └────────┘  └┘  
src                              └────────┘     └────────┘    └────────┘     
typ                              └────────┘ └┘  └────────┘   └────────┘  └┘  
doc    └──┘                      └────────┘      └────────┘     └────────┘
793  funext $ assume _, filter_eq $ rfl
id   └────┘            └───────┘   └─┘
src  └────┘             └───────┘   └─┘
typ  └────┘            └───────┘   └─┘
794  
795  @[simp] lemma map_map : filter.map m' (filter.map m f) = filter.map (m' ∘ m) f :=
id                           └────────┘ └┘  └────────┘     └────────┘  └┘    
src                          └────────┘     └────────┘       └────────┘     
typ                          └────────┘ └┘  └────────┘     └────────┘  └┘    
doc    └──┘                  └────────┘     └────────┘        └────────┘
796  congr_fun (@@filter.map_compose m m') f
id   └───────┘    └────────────────┘  └┘  
src  └───────┘    └────────────────┘
typ  └───────┘    └────────────────┘  └┘  
797  
798  end map
799  
800  section comap
801  
802  /-- The inverse map of a filter -/
803  def comap (m : α → β) (f : filter β) : filter α :=
id                            └────┘     └────┘ 
src                             └────┘      └────┘
typ                           └────┘     └────┘ 
804  { sets             := { s | ∃t∈ f, m ⁻¹' t ⊆ s },
id                                 └─┘   
src                                    └─┘   
typ                                └─┘   
doc                                       └─┘
805    univ_sets        := ⟨univ, univ_mem_sets, by simp only [subset_univ, preimage_univ]⟩,
id                          └──┘  └───────────┘                └─────────┘  └───────────┘
src                         └──┘  └───────────┘     └─────────┘└─────────┘└┘└───────────┘
typ                         └──┘  └───────────┘     └─────────┘└─────────┘└┘└───────────┘
doc                                                 └─────────┘           └┘             
txt                                                 └─────────┘           └┘             
par                                                 └─────────┘           └┘             
pid                                                     └──┘└┘           └┘             
st                                                 └─────────────────────────────────────┘
806    sets_of_superset := assume a b ⟨a', ha', ma'a⟩ ab,
id                                  └┘  └─┘  └──┘  └┘
typ                                 └┘  └─┘  └──┘  └┘
807      ⟨a', ha', subset.trans ma'a ab⟩,
id                 └──────────┘      └┘
src                └──────────┘
typ                └──────────┘      └┘
808    inter_sets       := assume a b ⟨a', ha₁, ha₂⟩ ⟨b', hb₁, hb₂⟩,
id                                  └┘  └─┘  └─┘  └┘  └─┘  └─┘
typ                                 └┘  └─┘  └─┘  └┘  └─┘  └─┘
809      ⟨a' ∩ b', inter_mem_sets ha₁ hb₁, inter_subset_inter ha₂ hb₂⟩ }
id                └────────────┘          └────────────────┘
src               └────────────┘          └────────────────┘
typ               └────────────┘          └────────────────┘
810  
811  end comap
812  
813  /-- The cofinite filter is the filter of subsets whose complements are finite. -/
814  def cofinite : filter α :=
id                  └────┘ 
src                 └────┘
typ                 └────┘ 
815  { sets             := {s | finite (- s)},
id                            └────┘   
src                            └────┘  
typ                           └────┘   
doc                             └────┘
816    univ_sets        := by simp only [compl_univ, finite_empty, mem_set_of_eq],
id                                       └────────┘  └──────────┘  └───────────┘
src                           └─────────┘└────────┘└┘└──────────┘└┘└───────────┘
typ                           └─────────┘└────────┘└┘└──────────┘└┘└───────────┘
doc                           └─────────┘          └┘            └┘             
txt                           └─────────┘          └┘            └┘             
par                           └─────────┘          └┘            └┘             
pid                               └──┘└┘          └┘            └┘             
st                           └──────────────────────────────────────────────────┘
817    sets_of_superset := assume s t (hs : finite (-s)) (st: s ⊆ t),
id                                        └────┘            
src                                         └────┘             
typ                                       └────┘            
doc                                         └────┘
818      finite_subset hs $ @lattice.neg_le_neg (set α) _ _ _ st,
id       └───────────┘ └┘    └────────────────┘  └─┘         └┘
src      └───────────┘       └────────────────┘  └─┘
typ      └───────────┘ └┘    └────────────────┘  └─┘         └┘
819    inter_sets       := assume s t (hs : finite (-s)) (ht : finite (-t)),
id                                        └────┘           └────┘  
src                                         └────┘            └────┘  
typ                                       └────┘           └────┘  
doc                                         └────┘             └────┘
820      by simp only [compl_inter, finite_union, ht, hs, mem_set_of_eq] }
id                     └─────────┘  └──────────┘  └┘  └┘  └───────────┘
src         └─────────┘└─────────┘└┘└──────────┘└┘  └┘  └┘└───────────┘└┘
typ         └─────────┘└─────────┘└┘└──────────┘└┘└┘└┘└┘└┘└───────────┘└┘
doc         └─────────┘           └┘            └┘  └┘  └┘             └┘
txt         └─────────┘           └┘            └┘  └┘  └┘             └┘
par         └─────────┘           └┘            └┘  └┘  └┘             └┘
pid             └──┘└┘           └┘            └┘  └┘  └┘             
st         └────────────────────────────────────────────────────────────┘
821  
822  @[simp] lemma mem_cofinite {s : set α} : s ∈ (@cofinite α) ↔ finite (-s) := iff.rfl
id                                   └─┘         └──────┘    └────┘       └─────┘
src                                  └─┘           └──────┘     └────┘        └─────┘
typ                                  └─┘         └──────┘    └────┘       └─────┘
doc    └──┘                                         └──────┘      └────┘
823  
824  lemma cofinite_ne_bot [infinite α] : @cofinite α ≠ ⊥ :=
id                          └──────┘      └──────┘   
src                         └──────┘       └──────┘    
typ                         └──────┘      └──────┘   
doc                                        └──────┘
825  mt empty_in_sets_eq_bot.mpr $ by { simp only [mem_cofinite, compl_empty], exact infinite_univ }
id   └┘ └──────────────────┘└──┘                   └──────────┘  └─────────┘         └───────────┘
src  └┘ └──────────────────┘└──┘        └─────────┘└──────────┘└┘└─────────┘  └────┘└───────────┘
typ  └┘ └──────────────────┘└──┘        └─────────┘└──────────┘└┘└─────────┘  └────┘└───────────┘
doc                                     └─────────┘            └┘             └────┘             
txt                                     └─────────┘            └┘             └────┘             
par                                     └─────────┘            └┘             └────┘             
pid                                         └──┘└┘            └┘                               
st                                   └──────────────────────────────────────┘└────────────────────┘└┘
826  
827  lemma frequently_cofinite_iff_infinite {p : α → Prop} :
id                                               
typ                                              
828    (∃ᶠ x in cofinite, p x) ↔ set.infinite {x | p x} :=
id      └┘  └┘ └──────┘     └──────────┘     
src     └┘   └┘ └──────┘       └──────────┘ 
typ     └┘  └┘ └──────┘     └──────────┘     
doc     └┘   └┘ └──────┘        └──────────┘
829  by simp only [filter.frequently, filter.eventually, mem_cofinite, compl_set_of, not_not,
id                 └───────────────┘  └───────────────┘  └──────────┘  └──────────┘  └─────┘
src     └─────────┘└───────────────┘└┘└───────────────┘└┘└──────────┘└┘└──────────┘└┘└─────┘└─
typ     └─────────┘└───────────────┘└┘└───────────────┘└┘└──────────┘└┘└──────────┘└┘└─────┘└─
doc     └─────────┘└───────────────┘└┘└───────────────┘└┘            └┘            └┘       └─
txt     └─────────┘                 └┘                 └┘            └┘            └┘       └─
par     └─────────┘                 └┘                 └┘            └┘            └┘       └─
pid         └──┘└┘                 └┘                 └┘            └┘            └┘       └─
st     └──────────────────────────────────────────────────────────────────────────────────────
830    set.infinite]
id     └──────────┘
src  ─┘└──────────┘└─
typ  ─┘└──────────┘└─
doc  ─┘└──────────┘└─
txt  ─┘            └─
par  ─┘            └─
pid  ─┘            
st   ────────────────
831  
src  
typ  
doc  
txt  
par  
pid  
st   
832  /-- The monadic bind operation on filter is defined the usual way in terms of `map` and `join`.
833  
834  Unfortunately, this `bind` does not result in the expected applicative. See `filter.seq` for the
835  applicative instance. -/
836  def bind (f : filter α) (m : α → filter β) : filter β := join (map m f)
id                 └────┘           └────┘     └────┘     └──┘  └─┘  
src                └────┘             └────┘      └────┘      └──┘  └─┘
typ                └────┘           └────┘     └────┘     └──┘  └─┘  
doc                                                           └──┘  └─┘
837  
838  /-- The applicative sequentiation operation. This is not induced by the bind operation. -/
839  def seq (f : filter (α → β)) (g : filter α) : filter β :=
id                └────┘             └────┘     └────┘ 
src               └────┘               └────┘      └────┘
typ               └────┘             └────┘     └────┘ 
840  ⟨{ s | ∃u∈ f, ∃t∈ g, (∀m∈u, ∀x∈t, (m : α → β) x ∈ s) },
id                                  
src                                             
typ                                 
841    ⟨univ, univ_mem_sets, univ, univ_mem_sets, by simp only [forall_prop_of_true, mem_univ, forall_true_iff]⟩,
id      └──┘  └───────────┘  └──┘  └───────────┘                └─────────────────┘  └──────┘  └─────────────┘
src     └──┘  └───────────┘  └──┘  └───────────┘     └─────────┘└─────────────────┘└┘└──────┘└┘└─────────────┘
typ     └──┘  └───────────┘  └──┘  └───────────┘     └─────────┘└─────────────────┘└┘└──────┘└┘└─────────────┘
doc                                                  └─────────┘                   └┘        └┘               
txt                                                  └─────────┘                   └┘        └┘               
par                                                  └─────────┘                   └┘        └┘               
pid                                                      └──┘└┘                   └┘        └┘               
st                                                  └─────────────────────────────────────────────────────────┘
842    assume s₀ s₁ ⟨t₀, t₁, h₀, h₁, h⟩ hst, ⟨t₀, t₁, h₀, h₁, assume x hx y hy, hst $ h _ hx _ hy⟩,
id            └┘ └┘ └┘  └┘  └┘  └┘    └─┘                           └┘  └┘  └─┘       └┘   └┘
typ           └┘ └┘ └┘  └┘  └┘  └┘    └─┘                           └┘  └┘  └─┘       └┘   └┘
843    assume s₀ s₁ ⟨t₀, ht₀, t₁, ht₁, ht⟩ ⟨u₀, hu₀, u₁, hu₁, hu⟩,
id            └┘ └┘ └┘  └─┘  └┘  └─┘  └┘  └┘  └─┘  └┘  └─┘  └┘
typ           └┘ └┘ └┘  └─┘  └┘  └─┘  └┘  └┘  └─┘  └┘  └─┘  └┘
844      ⟨t₀ ∩ u₀, inter_mem_sets ht₀ hu₀, t₁ ∩ u₁, inter_mem_sets ht₁ hu₁,
id                └────────────┘                  └────────────┘
src               └────────────┘                  └────────────┘
typ               └────────────┘                  └────────────┘
845        assume x ⟨hx₀, hx₁⟩ x ⟨hy₀, hy₁⟩, ⟨ht _ hx₀ _ hy₀, hu _ hx₁ _ hy₁⟩⟩⟩
id                 └─┘  └─┘   └─┘  └─┘
typ                └─┘  └─┘   └─┘  └─┘
846  
847  /-- `pure x` is the set of sets that contain `x`. It is equal to `principal {x}` but
848  with this definition we have `s ∈ pure a` defeq `a ∈ s`. -/
849  instance : has_pure filter :=
id              └──────┘ └────┘
src             └──────┘ └────┘
typ             └──────┘ └────┘
850  ⟨λ (α : Type u) x,
id           └──┘    
typ          └──┘    
851    { sets := {s | x ∈ s},
id                    
src                    
typ                   
852      inter_sets := λ s t, and.intro,
id                          └───────┘
src                           └───────┘
typ                         └───────┘
853      sets_of_superset := λ s t hs hst, hst hs,
id                               └┘ └─┘  └─┘ └┘
typ                              └┘ └─┘  └─┘ └┘
854      univ_sets := trivial }⟩
id                    └─────┘
src                   └─────┘
typ                   └─────┘
855  
856  instance : has_bind filter := ⟨@filter.bind⟩
id              └──────┘ └────┘      └─────────┘
src             └──────┘ └────┘      └─────────┘
typ             └──────┘ └────┘      └─────────┘
doc                                  └─────────┘
857  
858  instance : has_seq filter := ⟨@filter.seq⟩
id              └─────┘ └────┘      └────────┘
src             └─────┘ └────┘      └────────┘
typ             └─────┘ └────┘      └────────┘
doc                                 └────────┘
859  
860  instance : functor filter := { map := @filter.map }
id              └─────┘ └────┘              └────────┘
src             └─────┘ └────┘              └────────┘
typ             └─────┘ └────┘              └────────┘
doc                                         └────────┘
861  
862  lemma pure_sets (a : α) : (pure a : filter α).sets = {s | a ∈ s} := rfl
id                             └──┘    └────┘  └──┘             └─┘
src                             └──┘     └────┘   └──┘                └─┘
typ                            └──┘    └────┘  └──┘             └─┘
863  
864  @[simp] lemma mem_pure_sets {a : α} {s : set α} : s ∈ (pure a : filter α) ↔ a ∈ s := iff.rfl
id                                           └─┘        └──┘    └────┘          └─────┘
src                                           └─┘          └──┘     └────┘             └─────┘
typ                                          └─┘        └──┘    └────┘          └─────┘
doc    └──┘
865  
866  lemma pure_eq_principal (a : α) : (pure a : filter α) = principal {a} :=
id                                     └──┘    └────┘    └───────┘ 
src                                     └──┘     └────┘     └───────┘ 
typ                                    └──┘    └────┘    └───────┘ 
doc                                                          └───────┘
867  filter.ext $ λ s, by simp only [mem_pure_sets, mem_principal_sets, singleton_subset_iff]
id   └────────┘                     └───────────┘  └────────────────┘  └──────────────────┘
src  └────────┘           └─────────┘└───────────┘└┘└────────────────┘└┘└──────────────────┘└─
typ  └────────┘          └─────────┘└───────────┘└┘└────────────────┘└┘└──────────────────┘└─
doc                       └─────────┘             └┘                  └┘                    └─
txt                       └─────────┘             └┘                  └┘                    └─
par                       └─────────┘             └┘                  └┘                    └─
pid                           └──┘└┘             └┘                  └┘                    
st                       └────────────────────────────────────────────────────────────────────
868  
src  
typ  
doc  
txt  
par  
pid  
st   
869  @[simp] lemma map_pure (f : α → β) (a : α) : map f (pure a) = pure (f a) :=
id                                             └─┘   └──┘    └──┘   
src                                               └─┘    └──┘     └──┘
typ                                            └─┘   └──┘    └──┘   
doc    └──┘                                       └─┘
870  filter.ext $ λ s, iff.rfl
id   └────────┘       └─────┘
src  └────────┘        └─────┘
typ  └────────┘       └─────┘
871  
872  @[simp] lemma join_pure (f : filter α) : join (pure f) = f := filter.ext $ λ s, iff.rfl
id                                └────┘     └──┘  └──┘        └────────┘       └─────┘
src                               └────┘      └──┘  └──┘          └────────┘        └─────┘
typ                               └────┘     └──┘  └──┘        └────────┘       └─────┘
doc    └──┘                                   └──┘
873  
874  @[simp] lemma pure_bind (a : α) (m : α → filter β) :
id                                          └────┘ 
src                                           └────┘
typ                                         └────┘ 
doc    └──┘
875    bind (pure a) m = m a :=
id     └──┘  └──┘      
src    └──┘  └──┘      
typ    └──┘  └──┘      
doc    └──┘
876  by simp only [has_bind.bind, bind, map_pure, join_pure]
id                                └──┘  └──────┘  └───────┘
src     └─────────┘             └┘└──┘└┘└──────┘└┘└───────┘└─
typ     └─────────┘             └┘└──┘└┘└──────┘└┘└───────┘└─
doc     └─────────┘             └┘└──┘└┘        └┘         └─
txt     └─────────┘             └┘    └┘        └┘         └─
par     └─────────┘             └┘    └┘        └┘         └─
pid         └──┘└┘             └┘    └┘        └┘         
st     └─────────────────────────────────────────────────────
877  
src  
typ  
doc  
txt  
par  
pid  
st   
878  section
879  -- this section needs to be before applicative, otherwise the wrong instance will be chosen
880  protected def monad : monad filter := { map := @filter.map }
id                         └───┘ └────┘              └────────┘
src                        └───┘ └────┘              └────────┘
typ                        └───┘ └────┘              └────────┘
doc                                                  └────────┘
881  
882  local attribute [instance] filter.monad
id                              └──────────┘
src                             └──────────┘
typ                             └──────────┘
883  protected lemma is_lawful_monad : is_lawful_monad filter :=
id                                     └─────────────┘ └────┘
src                                    └─────────────┘ └────┘
typ                                    └─────────────┘ └────┘
884  { id_map     := assume α f, filter_eq rfl,
id                            └───────┘ └─┘
src                             └───────┘ └─┘
typ                           └───────┘ └─┘
885    pure_bind  := assume α β, pure_bind,
id                             └───────┘
src                              └───────┘
typ                            └───────┘
886    bind_assoc := assume α β γ f m₁ m₂, filter_eq rfl,
id                              └┘ └┘  └───────┘ └─┘
src                                        └───────┘ └─┘
typ                             └┘ └┘  └───────┘ └─┘
887    bind_pure_comp_eq_map := assume α β f x, filter.ext $ λ s,
id                                          └────────┘     
src                                             └────────┘
typ                                         └────────┘     
888      by simp only [has_bind.bind, bind, functor.map, mem_map, mem_join_sets, mem_set_of_eq,
id                                    └──┘               └─────┘  └───────────┘  └───────────┘
src         └─────────┘             └┘└──┘└┘           └┘└─────┘└┘└───────────┘└┘└───────────┘└─
typ         └─────────┘             └┘└──┘└┘           └┘└─────┘└┘└───────────┘└┘└───────────┘└─
doc         └─────────┘             └┘└──┘└┘           └┘       └┘             └┘             └─
txt         └─────────┘             └┘    └┘           └┘       └┘             └┘             └─
par         └─────────┘             └┘    └┘           └┘       └┘             └┘             └─
pid             └──┘└┘             └┘    └┘           └┘       └┘             └┘             └─
st         └────────────────────────────────────────────────────────────────────────────────────
889        function.comp, mem_pure_sets] }
id         └───────────┘  └───────────┘
src  ─────┘└───────────┘└┘└───────────┘└┘
typ  ─────┘└───────────┘└┘└───────────┘└┘
doc  ─────┘             └┘             └┘
txt  ─────┘             └┘             └┘
par  ─────┘             └┘             └┘
pid  ─────┘             └┘             
st   ───────────────────────────────────┘
890  end
891  
892  instance : applicative filter := { map := @filter.map, seq := @filter.seq }
id              └─────────┘ └────┘              └────────┘          └────────┘
src             └─────────┘ └────┘              └────────┘          └────────┘
typ             └─────────┘ └────┘              └────────┘          └────────┘
doc                                             └────────┘          └────────┘
893  
894  instance : alternative filter :=
id              └─────────┘ └────┘
src             └─────────┘ └────┘
typ             └─────────┘ └────┘
895  { failure := λα, ⊥,
id                   
src                   
typ                  
896    orelse  := λα x y, x ⊔ y }
id                       
src                         
typ                      
897  
898  @[simp] lemma map_def {α β} (m : α → β) (f : filter α) : m <$> f = map m f := rfl
id                                              └────┘      └─┘   └─┘      └─┘
src                                               └────┘        └─┘    └─┘        └─┘
typ                                             └────┘      └─┘   └─┘      └─┘
doc    └──┘                                                             └─┘
899  
900  @[simp] lemma bind_def {α β} (f : filter α) (m : α → filter β) : f >>= m = bind f m := rfl
id                                     └────┘           └────┘      └─┘   └──┘      └─┘
src                                    └────┘             └────┘        └─┘    └──┘        └─┘
typ                                    └────┘           └────┘      └─┘   └──┘      └─┘
doc    └──┘                                                                     └──┘
901  
902  /- map and comap equations -/
903  section map
904  variables {f f₁ f₂ : filter α} {g g₁ g₂ : filter β} {m : α → β} {m' : β → γ} {s : set α} {t : set β}
id                        └────┘               └────┘                                  └─┘         └─┘
src                       └────┘               └────┘                                  └─┘         └─┘
typ                       └────┘               └────┘                                  └─┘         └─┘
905  
906  @[simp] theorem mem_comap_sets : s ∈ comap m g ↔ ∃t∈ g, m ⁻¹' t ⊆ s := iff.rfl
id                                      └───┘        └─┘       └─────┘
src                                      └───┘             └─┘         └─────┘
typ                                     └───┘        └─┘       └─────┘
doc    └──┘                               └───┘                └─┘
907  
908  theorem preimage_mem_comap (ht : t ∈ g) : m ⁻¹' t ∈ comap m g :=
id                                           └─┘   └───┘  
src                                             └─┘    └───┘
typ                                          └─┘   └───┘  
doc                                              └─┘     └───┘
909  ⟨t, ht, subset.refl _⟩
id      └┘  └─────────┘
src          └─────────┘
typ     └┘  └─────────┘
910  
911  lemma comap_id : comap id f = f :=
id                    └───┘ └┘   
src                   └───┘ └┘   
typ                   └───┘ └┘   
doc                   └───┘
912  le_antisymm (assume s, preimage_mem_comap) (assume s ⟨t, ht, hst⟩, mem_sets_of_superset ht hst)
id   └─────────┘           └────────────────┘              └┘  └─┘   └──────────────────┘
src  └─────────┘            └────────────────┘                          └──────────────────┘
typ  └─────────┘           └────────────────┘              └┘  └─┘   └──────────────────┘
913  
914  lemma comap_comap_comp {m : γ → β} {n : β → α} : comap m (comap n f) = comap (n ∘ m) f :=
id                                                └───┘   └───┘     └───┘      
src                                                   └───┘    └───┘       └───┘    
typ                                               └───┘   └───┘     └───┘      
doc                                                   └───┘    └───┘        └───┘
915  le_antisymm
id   └─────────┘
src  └─────────┘
typ  └─────────┘
916    (assume c ⟨b, hb, (h : preimage (n ∘ m) b ⊆ c)⟩, ⟨preimage n b, preimage_mem_comap hb, h⟩)
id                └┘      └──────┘              └──────┘     └────────────────┘
src                           └──────┘                 └──────┘      └────────────────┘
typ               └┘      └──────┘              └──────┘     └────────────────┘
doc                           └──────┘                   └──────┘
917    (assume c ⟨b, ⟨a, ha, (h₁ : preimage n a ⊆ b)⟩, (h₂ : preimage m b ⊆ c)⟩,
id                    └┘       └──────┘               └──────┘     
src                                └──────┘                 └──────┘     
typ                   └┘       └──────┘               └──────┘     
doc                                └──────┘                  └──────┘
918      ⟨a, ha, show preimage m (preimage n a) ⊆ c, from subset.trans (preimage_mono h₁) h₂⟩)
id                    └──────┘   └──────┘             └──────────┘  └───────────┘
src                   └──────┘    └──────┘               └──────────┘  └───────────┘
typ                   └──────┘   └──────┘             └──────────┘  └───────────┘
doc                   └──────┘    └──────┘
919  
920  @[simp] theorem comap_principal {t : set β} : comap m (principal t) = principal (m ⁻¹' t) :=
id                                        └─┘     └───┘   └───────┘    └───────┘   └─┘ 
src                                       └─┘      └───┘    └───────┘     └───────┘    └─┘
typ                                       └─┘     └───┘   └───────┘    └───────┘   └─┘ 
doc    └──┘                                        └───┘    └───────┘      └───────┘    └─┘
921  filter_eq $ set.ext $ assume s,
id   └───────┘   └─────┘          
src  └───────┘   └─────┘
typ  └───────┘   └─────┘          
922    ⟨assume ⟨u, (hu : t ⊆ u), (b : preimage m u ⊆ s)⟩, subset.trans (preimage_mono hu) b,
id                               └──────┘         └──────────┘  └───────────┘
src                                  └──────┘           └──────────┘  └───────────┘
typ                              └──────┘         └──────────┘  └───────────┘
doc                                   └──────┘
923      assume : preimage m t ⊆ s, ⟨t, subset.refl t, this⟩⟩
id                └──────┘         └─────────┘   └──┘
src               └──────┘             └─────────┘
typ               └──────┘         └─────────┘   └──┘
doc               └──────┘
924  
925  lemma map_le_iff_le_comap : map m f ≤ g ↔ f ≤ comap m g :=
id                               └─┘        └───┘  
src                              └─┘            └───┘
typ                              └─┘        └───┘  
doc                              └─┘               └───┘
926  ⟨assume h s ⟨t, ht, hts⟩, mem_sets_of_superset (h ht) hts, assume h s ht, h ⟨_, ht, subset.refl _⟩⟩
id                └┘  └─┘   └──────────────────┘                     └┘       └┘  └─────────┘
src                            └──────────────────┘                                      └─────────┘
typ               └┘  └─┘   └──────────────────┘                     └┘       └┘  └─────────┘
927  
928  lemma gc_map_comap (m : α → β) : galois_connection (map m) (comap m) :=
id                                  └───────────────┘  └─┘    └───┘ 
src                                   └───────────────┘  └─┘     └───┘
typ                                 └───────────────┘  └─┘    └───┘ 
doc                                   └───────────────┘  └─┘     └───┘
929  assume f g, map_le_iff_le_comap
id             └─────────────────┘
src              └─────────────────┘
typ            └─────────────────┘
930  
931  lemma map_mono : monotone (map m) := (gc_map_comap m).monotone_l
id                    └──────┘  └─┘       └──────────┘  └────────┘
src                   └──────┘  └─┘        └──────────┘   └────────┘
typ                   └──────┘  └─┘       └──────────┘  └────────┘
doc                   └──────┘  └─┘
932  lemma comap_mono : monotone (comap m) := (gc_map_comap m).monotone_u
id                      └──────┘  └───┘       └──────────┘  └────────┘
src                     └──────┘  └───┘        └──────────┘   └────────┘
typ                     └──────┘  └───┘       └──────────┘  └────────┘
doc                     └──────┘  └───┘
933  
934  @[simp] lemma map_bot : map m ⊥ = ⊥ := (gc_map_comap m).l_bot
id                           └─┘         └──────────┘  └───┘
src                          └─┘          └──────────┘   └───┘
typ                          └─┘         └──────────┘  └───┘
doc    └──┘                  └─┘
935  @[simp] lemma map_sup : map m (f₁ ⊔ f₂) = map m f₁ ⊔ map m f₂ := (gc_map_comap m).l_sup
id                           └─┘   └┘  └┘   └─┘  └┘  └─┘  └┘     └──────────┘  └───┘
src                          └─┘             └─┘       └─┘          └──────────┘   └───┘
typ                          └─┘   └┘  └┘   └─┘  └┘  └─┘  └┘     └──────────┘  └───┘
doc    └──┘                  └─┘               └─┘        └─┘
936  @[simp] lemma map_supr {f : ι → filter α} : map m (⨆i, f i) = (⨆i, map m (f i)) :=
id                                  └────┘     └─┘          └─┘    
src                                  └────┘      └─┘               └─┘
typ                                 └────┘     └─┘          └─┘    
doc    └──┘                                      └─┘                └─┘
937  (gc_map_comap m).l_supr
id    └──────────┘  └────┘
src   └──────────┘   └────┘
typ   └──────────┘  └────┘
938  
939  @[simp] lemma comap_top : comap m ⊤ = ⊤ := (gc_map_comap m).u_top
id                             └───┘         └──────────┘  └───┘
src                            └───┘          └──────────┘   └───┘
typ                            └───┘         └──────────┘  └───┘
doc    └──┘                    └───┘
940  @[simp] lemma comap_inf : comap m (g₁ ⊓ g₂) = comap m g₁ ⊓ comap m g₂ := (gc_map_comap m).u_inf
id                             └───┘   └┘  └┘   └───┘  └┘  └───┘  └┘     └──────────┘  └───┘
src                            └───┘             └───┘       └───┘          └──────────┘   └───┘
typ                            └───┘   └┘  └┘   └───┘  └┘  └───┘  └┘     └──────────┘  └───┘
doc    └──┘                    └───┘               └───┘        └───┘
941  @[simp] lemma comap_infi {f : ι → filter β} : comap m (⨅i, f i) = (⨅i, comap m (f i)) :=
id                                    └────┘     └───┘          └───┘    
src                                    └────┘      └───┘               └───┘
typ                                   └────┘     └───┘          └───┘    
doc    └──┘                                        └───┘                └───┘
942  (gc_map_comap m).u_infi
id    └──────────┘  └────┘
src   └──────────┘   └────┘
typ   └──────────┘  └────┘
943  
944  lemma le_comap_top (f : α → β) (l : filter α) : l ≤ comap f ⊤ :=
id                                     └────┘       └───┘  
src                                      └────┘         └───┘   
typ                                    └────┘       └───┘  
doc                                                      └───┘
945  by rw [comap_top]; exact le_top
id          └───────┘         └────┘
src     └──┘└───────┘  └────┘└────┘
typ     └──┘└───────┘  └────┘└────┘
doc     └──┘           └────┘      
txt     └──┘           └────┘      
par     └──┘           └────┘      
pid       └┘                      
st     └────────────┘└──────────────
946  
src  
typ  
doc  
txt  
par  
pid  
st   
947  lemma map_comap_le : map m (comap m g) ≤ g := (gc_map_comap m).l_u_le _
id                        └─┘   └───┘          └──────────┘  └────┘
src                       └─┘    └───┘             └──────────┘   └────┘
typ                       └─┘   └───┘          └──────────┘  └────┘
doc                       └─┘    └───┘
948  lemma le_comap_map : f ≤ comap m (map m f) := (gc_map_comap m).le_u_l _
id                          └───┘   └─┘        └──────────┘  └────┘
src                          └───┘    └─┘          └──────────┘   └────┘
typ                         └───┘   └─┘        └──────────┘  └────┘
doc                           └───┘    └─┘
949  
950  @[simp] lemma comap_bot : comap m ⊥ = ⊥ :=
id                             └───┘    
src                            └───┘     
typ                            └───┘    
doc    └──┘                    └───┘
951  bot_unique $ assume s _, ⟨∅, by simp only [mem_bot_sets], by simp only [empty_subset, preimage_empty]⟩
id   └────────┘                              └──────────┘                 └──────────┘  └────────────┘
src  └────────┘                     └─────────┘└──────────┘     └─────────┘└──────────┘└┘└────────────┘
typ  └────────┘                   └─────────┘└──────────┘     └─────────┘└──────────┘└┘└────────────┘
doc                                  └─────────┘                 └─────────┘            └┘              
txt                                  └─────────┘                 └─────────┘            └┘              
par                                  └─────────┘                 └─────────┘            └┘              
pid                                      └──┘└┘                     └──┘└┘            └┘              
st                                  └───────────────────────┘    └───────────────────────────────────────┘
952  
953  lemma comap_supr {ι} {f : ι → filter β} {m : α → β} :
id                                └────┘           
src                                └────┘
typ                               └────┘           
954    comap m (supr f) = (⨆i, comap m (f i)) :=
id     └───┘   └──┘      └───┘    
src    └───┘    └──┘        └───┘
typ    └───┘   └──┘      └───┘    
doc    └───┘    └──┘         └───┘
955  le_antisymm
id   └─────────┘
src  └─────────┘
typ  └─────────┘
956    (assume s hs,
id              └┘
typ             └┘
957      have ∀i, ∃t, t ∈ f i ∧ m ⁻¹' t ⊆ s, by simpa only [mem_comap_sets, exists_prop, mem_supr_sets] using mem_supr_sets.1 hs,
id                      └─┘                    └────────────┘  └─────────┘  └───────────┘        └───────────┘   └┘
src                           └─┘          └──────────┘└────────────┘└┘└─────────┘└┘└───────────┘└──────┘└───────────┘└─┘
typ                     └─┘        └──────────┘└────────────┘└┘└─────────┘└┘└───────────┘└──────┘└───────────┘└─┘└┘
doc                               └─┘           └──────────┘              └┘           └┘             └──────┘             └─┘
txt                                             └──────────┘              └┘           └┘             └──────┘             └─┘
par                                             └──────────┘              └┘           └┘             └──────┘             └─┘
pid                                                  └──┘└┘              └┘           └┘             └────┘             └─┘
st                                             └───────────────────────────────────────────────────────────────────────────────┘
958      let ⟨t, ht⟩ := classical.axiom_of_choice this in
id       └─┘    └┘     └───────────────────────┘ └──┘
src                     └───────────────────────┘
typ      └─┘    └┘     └───────────────────────┘ └──┘
959      ⟨⋃i, t i, mem_supr_sets.2 $ assume i, (f i).sets_of_superset (ht i).1 (subset_Union _ _),
id             └───────────┘                └──────────────┘          └──────────┘
src              └───────────┘                   └──────────────┘           └──────────┘
typ            └───────────┘                └──────────────┘          └──────────┘
doc        
960        begin
st         └─────
961          rw [preimage_Union, Union_subset_iff],
id               └────────────┘  └──────────────┘
src          └──┘└────────────┘└┘└──────────────┘
typ          └──┘└────────────┘└┘└──────────────┘
doc          └──┘              └┘                
txt          └──┘              └┘                
par          └──┘              └┘                
pid            └┘              └┘                
st   ─────────────────────────┘└────────────────┘└──
962          assume i,
src          └──────┘
typ          └──────┘
doc          └──────┘
txt          └──────┘
par          └──────┘
pid          └──────┘
st   ───────────────┘└─
963          exact (ht i).2
id                  └┘ 
src          └────┘    └───
typ          └────┘ └┘└───
doc          └────┘    └───
txt          └────┘    └───
par          └────┘    └───
pid                   └──
st   ───────────────────────
964        end⟩)
src  ─────┘
typ  ─────┘
doc  ─────┘
txt  ─────┘
par  ─────┘
pid  ─────┘
st   ─────┘└─┘
965    (supr_le $ assume i, comap_mono $ le_supr _ _)
id      └─────┘            └────────┘   └─────┘
src     └─────┘             └────────┘   └─────┘
typ     └─────┘            └────────┘   └─────┘
966  
967  lemma comap_Sup {s : set (filter β)} {m : α → β} : comap m (Sup s) = (⨆f∈s, comap m f) :=
id                        └─┘  └────┘                └───┘   └─┘       └───┘  
src                       └─┘  └────┘                   └───┘    └─┘          └───┘
typ                       └─┘  └────┘                └───┘   └─┘       └───┘  
doc                                                     └───┘    └─┘           └───┘
968  by simp only [Sup_eq_supr, comap_supr, eq_self_iff_true]
id                 └─────────┘  └────────┘  └──────────────┘
src     └─────────┘└─────────┘└┘└────────┘└┘└──────────────┘└─
typ     └─────────┘└─────────┘└┘└────────┘└┘└──────────────┘└─
doc     └─────────┘           └┘          └┘                └─
txt     └─────────┘           └┘          └┘                └─
par     └─────────┘           └┘          └┘                └─
pid         └──┘└┘           └┘          └┘                
st     └──────────────────────────────────────────────────────
969  
src  
typ  
doc  
txt  
par  
pid  
st   
970  lemma comap_sup : comap m (g₁ ⊔ g₂) = comap m g₁ ⊔ comap m g₂ :=
id                     └───┘   └┘  └┘   └───┘  └┘  └───┘  └┘
src                    └───┘             └───┘       └───┘
typ                    └───┘   └┘  └┘   └───┘  └┘  └───┘  └┘
doc                    └───┘               └───┘        └───┘
971  le_antisymm
id   └─────────┘
src  └─────────┘
typ  └─────────┘
972    (assume s ⟨⟨t₁, ht₁, hs₁⟩, ⟨t₂, ht₂, hs₂⟩⟩,
id               └┘  └─┘  └─┘    └┘  └─┘  └─┘
typ              └┘  └─┘  └─┘    └┘  └─┘  └─┘
973      ⟨t₁ ∪ t₂,
id           
src          
typ          
974        ⟨g₁.sets_of_superset ht₁ (subset_union_left _ _), g₂.sets_of_superset ht₂ (subset_union_right _ _)⟩,
id          └┘└───────────────┘      └───────────────┘       └┘└───────────────┘      └────────────────┘
src           └───────────────┘      └───────────────┘         └───────────────┘      └────────────────┘
typ         └┘└───────────────┘      └───────────────┘       └┘└───────────────┘      └────────────────┘
975        union_subset hs₁ hs₂⟩)
id         └──────────┘
src        └──────────┘
typ        └──────────┘
976    ((@comap_mono _ _ m).le_map_sup _ _)
id        └────────┘      └────────┘
src       └────────┘       └────────┘
typ       └────────┘      └────────┘
977  
978  lemma map_comap {f : filter β} {m : α → β} (hf : range m ∈ f) : (f.comap m).map m = f :=
id                        └────┘                   └───┘        └────┘  └─┘    
src                       └────┘                      └───┘           └────┘   └─┘    
typ                       └────┘                   └───┘        └────┘  └─┘    
doc                                                   └───┘            └────┘   └─┘
979  le_antisymm
id   └─────────┘
src  └─────────┘
typ  └─────────┘
980    map_comap_le
id     └──────────┘
src    └──────────┘
typ    └──────────┘
981    (assume t' ⟨t, ht, sub⟩, by filter_upwards [ht, hf]; rintros x hxt ⟨y, rfl⟩; exact sub hxt)
id             └┘                                                                        └─┘ └─┘
src                                └──────────────┘  └┘    └────────────────────┘  └────┘   
typ            └┘                 └──────────────┘  └┘    └────────────────────┘  └────┘└─┘└─┘
doc                                └──────────────┘  └┘    └────────────────────┘  └────┘   
txt                                └──────────────┘  └┘    └────────────────────┘  └────┘   
par                                └──────────────┘  └┘    └────────────────────┘  └────┘   
pid                                              └┘  └┘           └─────────────┘          
st                                └─────────────────────────────────────────────────────────────┘
982  
983  lemma comap_map {f : filter α} {m : α → β} (h : ∀ x y, m x = m y → x = y) :
id                        └────┘                                
src                       └────┘                                         
typ                       └────┘                                
984    comap m (map m f) = f :=
id     └───┘   └─┘     
src    └───┘    └─┘      
typ    └───┘   └─┘     
doc    └───┘    └─┘
985  have ∀s, preimage m (image m s) = s,
id           └──────┘   └───┘     
src           └──────┘    └───┘      
typ          └──────┘   └───┘     
doc           └──────┘
986    from assume s, preimage_image_eq s h,
id                   └───────────────┘  
src                   └───────────────┘
typ                  └───────────────┘  
987  le_antisymm
id   └─────────┘
src  └─────────┘
typ  └─────────┘
988    (assume s hs, ⟨
id              └┘
typ             └┘
989      image m s,
id       └───┘  
src      └───┘
typ      └───┘  
990      f.sets_of_superset hs $ by simp only [this, subset.refl],
id       └───────────────┘ └┘                 └──┘  └─────────┘
src       └───────────────┘         └─────────┘    └┘└─────────┘
typ      └───────────────┘ └┘      └─────────┘└──┘└┘└─────────┘
doc                                 └─────────┘    └┘           
txt                                 └─────────┘    └┘           
par                                 └─────────┘    └┘           
pid                                     └──┘└┘    └┘           
st                                 └────────────────────────────┘
991      by simp only [this, subset.refl]⟩)
id                     └──┘  └─────────┘
src         └─────────┘    └┘└─────────┘
typ         └─────────┘└──┘└┘└─────────┘
doc         └─────────┘    └┘           
txt         └─────────┘    └┘           
par         └─────────┘    └┘           
pid             └──┘└┘    └┘           
st         └────────────────────────────┘
992    le_comap_map
id     └──────────┘
src    └──────────┘
typ    └──────────┘
993  
994  lemma le_of_map_le_map_inj' {f g : filter α} {m : α → β} {s : set α}
id                                      └────┘                  └─┘ 
src                                     └────┘                     └─┘
typ                                     └────┘                  └─┘ 
995    (hsf : s ∈ f) (hsg : s ∈ g) (hm : ∀x∈s, ∀y∈s, m x = m y → x = y)
id                                                  
src                                                             
typ                                                 
996    (h : map m f ≤ map m g) : f ≤ g :=
id          └─┘    └─┘        
src         └─┘      └─┘          
typ         └─┘    └─┘        
doc         └─┘       └─┘
997  assume t ht, by filter_upwards [hsf, h $ image_mem_map (inter_mem_sets hsg ht)]
id           └┘                             └───────────┘  └────────────┘ └─┘ └┘
src                  └──────────────┘   └┘  └───────────┘ └────────────┘     └─┘
typ          └┘     └──────────────┘   └┘ └───────────┘ └────────────┘└─┘└┘└─┘
doc                  └──────────────┘   └┘                                   └─┘
txt                  └──────────────┘   └┘                                   └─┘
par                  └──────────────┘   └┘                                   └─┘
pid                                └┘   └┘                                   └┘
st                  └────────────────────────────────────────────────────────────────
998  assume a has ⟨b, ⟨hbs, hb⟩, h⟩,
id                    └─┘  └┘   
src        └──────┘ └┘    └┘  └─┘ └─┘
typ        └──────┘└┘ └─┘└┘└┘└─┘└─┘
doc        └──────┘ └┘    └┘  └─┘ └─┘
txt        └──────┘ └┘    └┘  └─┘ └─┘
par        └──────┘ └┘    └┘  └─┘ └─┘
pid        └──────┘ └┘    └┘  └─┘ └─┘
st   ────────────────────────────────
999  have b = a, from hm _ hbs _ has h,
id                   └┘
src      └─┘ └─────┘  └─┘   └─┘    └┘
typ      └─┘ └─────┘└┘└─┘   └─┘    └┘
doc      └─┘  └─────┘  └─┘   └─┘    └┘
txt      └─┘  └─────┘  └─┘   └─┘    └┘
par      └─┘  └─────┘  └─┘   └─┘    └┘
pid      └─┘  └─────┘  └─┘   └─┘    └┘
st   ───────────────────────────────────
1000  this ▸ hb
id        
src        
typ        
doc         
txt         
par         
pid         
st   ──────────
1001  
src  
typ  
doc  
txt  
par  
pid  
st   
1002  lemma le_of_map_le_map_inj_iff {f g : filter α} {m : α → β} {s : set α}
id                                         └────┘                  └─┘ 
src                                        └────┘                     └─┘
typ                                        └────┘                  └─┘ 
1003    (hsf : s ∈ f) (hsg : s ∈ g) (hm : ∀x∈s, ∀y∈s, m x = m y → x = y) :
id                                                  
src                                                             
typ                                                 
1004    map m f ≤ map m g ↔ f ≤ g :=
id     └─┘    └─┘      
src    └─┘      └─┘        
typ    └─┘    └─┘      
doc    └─┘       └─┘
1005  iff.intro (le_of_map_le_map_inj' hsf hsg hm) (λ h, map_mono h)
id   └───────┘  └───────────────────┘ └─┘ └─┘ └┘       └──────┘ 
src  └───────┘  └───────────────────┘                   └──────┘
typ  └───────┘  └───────────────────┘ └─┘ └─┘ └┘       └──────┘ 
1006  
1007  lemma eq_of_map_eq_map_inj' {f g : filter α} {m : α → β} {s : set α}
id                                      └────┘                  └─┘ 
src                                     └────┘                     └─┘
typ                                     └────┘                  └─┘ 
1008    (hsf : s ∈ f) (hsg : s ∈ g) (hm : ∀x∈s, ∀y∈s, m x = m y → x = y)
id                                                  
src                                                             
typ                                                 
1009    (h : map m f = map m g) : f = g :=
id          └─┘    └─┘        
src         └─┘      └─┘          
typ         └─┘    └─┘        
doc         └─┘       └─┘
1010  le_antisymm
id   └─────────┘
src  └─────────┘
typ  └─────────┘
1011    (le_of_map_le_map_inj' hsf hsg hm $ le_of_eq h)
id      └───────────────────┘ └─┘ └─┘ └┘   └──────┘ 
src     └───────────────────┘              └──────┘
typ     └───────────────────┘ └─┘ └─┘ └┘   └──────┘ 
1012    (le_of_map_le_map_inj' hsg hsf hm $ le_of_eq h.symm)
id      └───────────────────┘ └─┘ └─┘ └┘   └──────┘ └───┘
src     └───────────────────┘              └──────┘  └───┘
typ     └───────────────────┘ └─┘ └─┘ └┘   └──────┘ └───┘
1013  
1014  lemma map_inj {f g : filter α} {m : α → β} (hm : ∀ x y, m x = m y → x = y) (h : map m f = map m g) :
id                        └────┘                                        └─┘    └─┘  
src                       └────┘                                                   └─┘      └─┘
typ                       └────┘                                        └─┘    └─┘  
doc                                                                                  └─┘       └─┘
1015    f = g :=
id       
src      
typ      
1016  have comap m (map m f) = comap m (map m g), by rw h,
id        └───┘   └─┘     └───┘   └─┘           
src       └───┘    └─┘       └───┘    └─┘          └─┘
typ       └───┘   └─┘     └───┘   └─┘        └─┘
doc       └───┘    └─┘        └───┘    └─┘          └─┘
txt                                                 └─┘
par                                                 └─┘
pid                                                   
st                                                 └───┘
1017  by rwa [comap_map hm, comap_map hm] at this
id           └───────┘ └┘  └───────┘ └┘
src     └───┘└───────┘  └┘└───────┘  └─────────
typ     └───┘└───────┘└┘└┘└───────┘└┘└─────────
doc     └───┘           └┘           └─────────
txt     └───┘           └┘           └─────────
par     └───┘           └┘           └─────────
pid        └┘           └┘           └──────┘
st     └────────────────┘└────────────┘└────────
1018  
src  
typ  
doc  
txt  
par  
pid  
st   
1019  theorem le_map_comap_of_surjective' {f : α → β} {l : filter β} {u : set β} (ul : u ∈ l)
id                                                      └────┘        └─┘           
src                                                       └────┘         └─┘            
typ                                                     └────┘        └─┘           
1020      (hf : ∀ y ∈ u, ∃ x, f x = y) :
id                         
src                            
typ                        
1021    l ≤ map f (comap f l) :=
id       └─┘   └───┘  
src       └─┘    └───┘
typ      └─┘   └───┘  
doc        └─┘    └───┘
1022  assume s ⟨t, tl, ht⟩,
id             └┘
typ            └┘
1023  have t ∩ u ⊆ s, from
id             
src            
typ            
1024    assume x ⟨xt, xu⟩,
id                 └┘
typ                └┘
1025    exists.elim (hf x xu) $ λ a faeq,
id     └─────────┘  └┘           └──┘
src    └─────────┘
typ    └─────────┘  └┘           └──┘
1026    by { rw ←faeq, apply ht, change f a ∈ t, rw faeq, exact xt },
id              └──┘                           └──┘        └┘
src         └──┘      └────┘    └─────┘     └─┘      └────┘  
typ         └──┘└──┘  └────┘    └─────┘  └─┘└──┘  └────┘└┘
doc         └──┘      └────┘    └─────┘      └─┘      └────┘  
txt         └──┘      └────┘    └─────┘      └─┘      └────┘  
par         └──┘      └────┘    └─────┘      └─┘      └────┘  
pid           └┘                                          
st       └─────────┘└────────┘└──────────────┘└───────┘└─────────┘└┘
1027  mem_sets_of_superset (inter_mem_sets tl ul) this
id   └──────────────────┘  └────────────┘    └┘  └──┘
src  └──────────────────┘  └────────────┘
typ  └──────────────────┘  └────────────┘    └┘  └──┘
1028  
1029  theorem map_comap_of_surjective' {f : α → β} {l : filter β} {u : set β} (ul : u ∈ l)
id                                                   └────┘        └─┘           
src                                                    └────┘         └─┘            
typ                                                  └────┘        └─┘           
1030      (hf : ∀ y ∈ u, ∃ x, f x = y)  :
id                         
src                            
typ                        
1031    map f (comap f l) = l :=
id     └─┘   └───┘     
src    └─┘    └───┘      
typ    └─┘   └───┘     
doc    └─┘    └───┘
1032  le_antisymm map_comap_le (le_map_comap_of_surjective' ul hf)
id   └─────────┘ └──────────┘  └─────────────────────────┘ └┘ └┘
src  └─────────┘ └──────────┘  └─────────────────────────┘
typ  └─────────┘ └──────────┘  └─────────────────────────┘ └┘ └┘
1033  
1034  theorem le_map_comap_of_surjective {f : α → β} (hf : function.surjective f) (l : filter β) :
id                                                      └─────────────────┘        └────┘ 
src                                                       └─────────────────┘         └────┘
typ                                                     └─────────────────┘        └────┘ 
1035    l ≤ map f (comap f l) :=
id       └─┘   └───┘  
src       └─┘    └───┘
typ      └─┘   └───┘  
doc        └─┘    └───┘
1036  le_map_comap_of_surjective' univ_mem_sets (λ y _, hf y)
id   └─────────────────────────┘ └───────────┘       └┘ 
src  └─────────────────────────┘ └───────────┘
typ  └─────────────────────────┘ └───────────┘       └┘ 
1037  
1038  theorem map_comap_of_surjective {f : α → β} (hf : function.surjective f) (l : filter β) :
id                                                   └─────────────────┘        └────┘ 
src                                                    └─────────────────┘         └────┘
typ                                                  └─────────────────┘        └────┘ 
1039    map f (comap f l) = l :=
id     └─┘   └───┘     
src    └─┘    └───┘      
typ    └─┘   └───┘     
doc    └─┘    └───┘
1040  le_antisymm map_comap_le (le_map_comap_of_surjective hf l)
id   └─────────┘ └──────────┘  └────────────────────────┘ └┘ 
src  └─────────┘ └──────────┘  └────────────────────────┘
typ  └─────────┘ └──────────┘  └────────────────────────┘ └┘ 
1041  
1042  lemma comap_ne_bot {f : filter β} {m : α → β} (hm : ∀t∈ f, ∃a, m a ∈ t) :
id                           └────┘                            
src                          └────┘                                   
typ                          └────┘                            
1043    comap m f ≠ ⊥ :=
id     └───┘    
src    └───┘      
typ    └───┘    
doc    └───┘
1044  forall_sets_nonempty_iff_ne_bot.mp $ assume s ⟨t, ht, t_s⟩,
id   └─────────────────────────────┘└─┘             └┘  └─┘
src  └─────────────────────────────┘└─┘
typ  └─────────────────────────────┘└─┘             └┘  └─┘
1045    set.nonempty.mono t_s (hm t ht)
id     └───────────────┘      └┘
src    └───────────────┘
typ    └───────────────┘      └┘
1046  
1047  lemma comap_ne_bot_of_range_mem {f : filter β} {m : α → β}
id                                        └────┘           
src                                       └────┘
typ                                       └────┘           
1048    (hf : f ≠ ⊥) (hm : range m ∈ f) : comap m f ≠ ⊥ :=
id                     └───┘       └───┘    
src                     └───┘         └───┘      
typ                    └───┘       └───┘    
doc                       └───┘          └───┘
1049  comap_ne_bot $ assume t ht,
id   └──────────┘           └┘
src  └──────────┘
typ  └──────────┘           └┘
1050    let ⟨_, ha, a, rfl⟩ := nonempty_of_mem_sets hf (inter_mem_sets ht hm)
id     └─┘     └┘    └─┘     └──────────────────┘ └┘  └────────────┘ └┘ └┘
src                   └─┘     └──────────────────┘     └────────────┘
typ    └─┘     └┘    └─┘     └──────────────────┘ └┘  └────────────┘ └┘ └┘
1051    in ⟨a, ha⟩
1052  
1053  lemma comap_inf_principal_ne_bot_of_image_mem {f : filter β} {m : α → β}
id                                                      └────┘           
src                                                     └────┘
typ                                                     └────┘           
1054    (hf : f ≠ ⊥) {s : set α} (hs : m '' s ∈ f) : (comap m f ⊓ principal s) ≠ ⊥ :=
id                    └─┘          └┘        └───┘    └───────┘    
src                    └─┘            └┘          └───┘      └───────┘     
typ                   └─┘          └┘        └───┘    └───────┘    
doc                                                  └───┘       └───────┘
1055  begin
st   └─────
1056    refine compl_compl s ▸ mt mem_sets_of_eq_bot _,
id            └─────────┘   └┘ └────────────────┘
src    └─────┘└─────────┘ └┘└────────────────┘└┘
typ    └─────┘└─────────┘└┘└────────────────┘└┘
doc    └─────┘                                 └┘
txt    └─────┘                                 └┘
par    └─────┘                                 └┘
pid                                           └┘
st   ───────────────────────────────────────────────┘└─
1057    rintros ⟨t, ht, hts⟩,
src    └──────────────────┘
typ    └──────────────────┘
doc    └──────────────────┘
txt    └──────────────────┘
par    └──────────────────┘
pid           └───────────┘
st   ─────────────────────┘└─
1058    rcases nonempty_of_mem_sets hf (inter_mem_sets hs ht) with ⟨_, ⟨x, hxs, rfl⟩, hxt⟩,
id            └──────────────────┘ └┘  └────────────┘ └┘ └┘
src    └─────┘└──────────────────┘   └────────────┘    └────────────────────────────┘
typ    └─────┘└──────────────────┘└┘ └────────────┘└┘└┘└────────────────────────────┘
doc    └─────┘                                         └────────────────────────────┘
txt    └─────┘                                         └────────────────────────────┘
par    └─────┘                                         └────────────────────────────┘
pid                                                   └────────────────────────────┘
st   ───────────────────────────────────────────────────────────────────────────────────┘└─
1059    exact absurd hxs (hts hxt)
id           └────┘ └─┘  └─┘ └─┘
src    └────┘└────┘          └┘
typ    └────┘└────┘└─┘ └─┘└─┘└┘
doc    └────┘                └┘
txt    └────┘                └┘
par    └────┘                └┘
pid                         
st   ────────────────────────────┘
1060  end
st   └─┘
1061  
1062  lemma comap_ne_bot_of_surj {f : filter β} {m : α → β}
id                                   └────┘           
src                                  └────┘
typ                                  └────┘           
1063    (hf : f ≠ ⊥) (hm : function.surjective m) : comap m f ≠ ⊥ :=
id                     └─────────────────┘     └───┘    
src                     └─────────────────┘      └───┘      
typ                    └─────────────────┘     └───┘    
doc                                                └───┘
1064  comap_ne_bot_of_range_mem hf $ univ_mem_sets' hm
id   └───────────────────────┘ └┘   └────────────┘ └┘
src  └───────────────────────┘      └────────────┘
typ  └───────────────────────┘ └┘   └────────────┘ └┘
1065  
1066  @[simp] lemma map_eq_bot_iff : map m f = ⊥ ↔ f = ⊥ :=
id                                  └─┘        
src                                 └─┘           
typ                                 └─┘        
doc    └──┘                         └─┘
1067  ⟨by rw [←empty_in_sets_eq_bot, ←empty_in_sets_eq_bot]; exact id,
id            └──────────────────┘   └──────────────────┘         └┘
src      └───┘└──────────────────┘└─┘└──────────────────┘  └────┘└┘
typ      └───┘└──────────────────┘└─┘└──────────────────┘  └────┘└┘
doc      └───┘                    └─┘                      └────┘
txt      └───┘                    └─┘                      └────┘
par      └───┘                    └─┘                      └────┘
pid        └─┘                    └─┘                           
st      └────────────────────────┘└─────────────────────┘└────────┘
1068    assume h, by simp only [h, eq_self_iff_true, map_bot]⟩
id                              └──────────────┘  └─────┘
src                 └─────────┘ └┘└──────────────┘└┘└─────┘
typ                └─────────┘└┘└──────────────┘└┘└─────┘
doc                 └─────────┘ └┘                └┘       
txt                 └─────────┘ └┘                └┘       
par                 └─────────┘ └┘                └┘       
pid                     └──┘└┘ └┘                └┘       
st                 └───────────────────────────────────────┘
1069  
1070  lemma map_ne_bot (hf : f ≠ ⊥) : map m f ≠ ⊥ :=
id                                └─┘    
src                                └─┘      
typ                               └─┘    
doc                                  └─┘
1071  assume h, hf $ by rwa [map_eq_bot_iff] at h
id            └┘           └────────────┘
src                    └───┘└────────────┘└──────
typ           └┘      └───┘└────────────┘└──────
doc                    └───┘              └──────
txt                    └───┘              └──────
par                    └───┘              └──────
pid                       └┘              └───┘
st                    └──────────────────┘└─────
1072  
src  
typ  
doc  
txt  
par  
pid  
st   
1073  lemma sInter_comap_sets (f : α → β) (F : filter β) :
id                                          └────┘ 
src                                           └────┘
typ                                         └────┘ 
1074    ⋂₀(comap f F).sets = ⋂ U ∈ F, f ⁻¹' U :=
id     └┘ └───┘   └──┘         └─┘ 
src    └┘ └───┘     └──┘            └─┘
typ    └┘ └───┘   └──┘         └─┘ 
doc    └┘ └───┘                      └─┘
1075  begin
st   └─────
1076    ext x,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
pid       └┘
st   ──────┘└─
1077    suffices : (∀ (A : set α) (B : set β), B ∈ F → f ⁻¹' B ⊆ A → x ∈ A) ↔
id                        └─┘        └─┘              └─┘   
src    └─────────┘  └────┘    └─────┘         └─┘      └┘ 
typ    └─────────┘  └────┘└─┘└─────┘└─┘      └─┘      └┘ 
doc    └─────────┘  └────┘    └─────┘          └─┘       └┘ 
txt    └─────────┘  └────┘    └─────┘                    └┘ 
par    └─────────┘  └────┘    └─────┘                    └┘ 
pid    └───────┘└┘  └────┘    └─────┘                    └┘ 
st   ────────────────────────────────────────────────────────────────────────
1078      ∀ (B : set β), B ∈ F → f x ∈ B,
id              └─┘            
src  ───┘ └────┘└─┘         
typ  ───┘ └────┘└─┘     
doc  ───┘ └────┘            
txt  ───┘ └────┘            
par  ───┘ └────┘            
pid  ───┘ └────┘            
st   ─────────────────────────────────┘
1079    by simp only [mem_sInter, mem_Inter, mem_comap_sets, this, and_imp, mem_comap_sets, exists_prop, mem_sInter,
id                   └────────┘  └───────┘  └────────────┘  └──┘  └─────┘  └────────────┘  └─────────┘  └────────┘
src       └─────────┘└────────┘└┘└───────┘└┘└────────────┘└┘    └┘└─────┘└┘└────────────┘└┘└─────────┘└┘└────────┘└─
typ       └─────────┘└────────┘└┘└───────┘└┘└────────────┘└┘└──┘└┘└─────┘└┘└────────────┘└┘└─────────┘└┘└────────┘└─
doc       └─────────┘          └┘         └┘              └┘    └┘       └┘              └┘           └┘          └─
txt       └─────────┘          └┘         └┘              └┘    └┘       └┘              └┘           └┘          └─
par       └─────────┘          └┘         └┘              └┘    └┘       └┘              └┘           └┘          └─
pid           └──┘└┘          └┘         └┘              └┘    └┘       └┘              └┘           └┘          └─
1080      iff_self, mem_Inter, mem_preimage, exists_imp_distrib],
id       └──────┘  └───────┘  └──────────┘  └────────────────┘
src  ───┘└──────┘└┘└───────┘└┘└──────────┘└┘└────────────────┘
typ  ───┘└──────┘└┘└───────┘└┘└──────────┘└┘└────────────────┘
doc  ───┘        └┘         └┘            └┘                  
txt  ───┘        └┘         └┘            └┘                  
par  ───┘        └┘         └┘            └┘                  
pid  ───┘        └┘         └┘            └┘                  
st                                                             └─
1081    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
1082    { intros h U U_in,
src      └─────────────┘
typ      └─────────────┘
doc      └─────────────┘
txt      └─────────────┘
par      └─────────────┘
pid            └───────┘
st   ───┘└─────────────┘└─
1083      simpa only [set.subset.refl, forall_prop_of_true, mem_preimage] using h (f ⁻¹' U) U U_in },
id                   └─────────────┘  └─────────────────┘  └──────────┘                   └──┘
src      └──────────┘└─────────────┘└┘└─────────────────┘└┘└──────────┘└──────┘       └┘     
typ      └──────────┘└─────────────┘└┘└─────────────────┘└┘└──────────┘└──────┘     └┘└──┘
doc      └──────────┘               └┘                   └┘            └──────┘       └┘     
txt      └──────────┘               └┘                   └┘            └──────┘       └┘     
par      └──────────┘               └┘                   └┘            └──────┘       └┘     
pid           └──┘└┘               └┘                   └┘            └────┘       └┘     
st   ────────────────────────────────────────────────────────────────────────────────────────────┘└┘
1084    { intros h V U U_in f_U_V,
src      └─────────────────────┘
typ      └─────────────────────┘
doc      └─────────────────────┘
txt      └─────────────────────┘
par      └─────────────────────┘
pid            └───────────────┘
st   ──────────────────────────┘└─
1085      exact f_U_V (h U U_in) },
id             └───┘    └──┘
src      └────┘            └┘
typ      └────┘└───┘ └──┘└┘
doc      └────┘            └┘
txt      └────┘            └┘
par      └────┘            └┘
pid                       
st   ──────────────────────────┘└──
1086  end
st   ──┘
1087  end map
1088  
1089  lemma map_cong {m₁ m₂ : α → β} {f : filter α} (h : {x | m₁ x = m₂ x} ∈ f) :
id                                     └────┘           └┘   └┘    
src                                      └────┘                         
typ                                    └────┘           └┘   └┘    
1090    map m₁ f = map m₂ f :=
id     └─┘ └┘   └─┘ └┘ 
src    └─┘       └─┘
typ    └─┘ └┘   └─┘ └┘ 
doc    └─┘        └─┘
1091  have ∀(m₁ m₂ : α → β) (h : {x | m₁ x = m₂ x} ∈ f), map m₁ f ≤ map m₂ f,
id                              └┘   └┘       └─┘ └┘   └─┘ └┘ 
src                                                  └─┘       └─┘
typ                             └┘   └┘       └─┘ └┘   └─┘ └┘ 
doc                                                     └─┘        └─┘
1092  begin
st   └─────
1093    intros  m₁ m₂ h s hs,
src    └──────────────────┘
typ    └──────────────────┘
doc    └──────────────────┘
txt    └──────────────────┘
par    └──────────────────┘
pid          └────────────┘
st   ─────────────────────┘└─
1094    show {x | m₁ x ∈ s} ∈ f,
id              └┘        
src    └───┘└──┘    └┘ 
typ    └───┘└──┘└┘ └┘ 
doc    └───┘ └──┘     └┘ 
txt    └───┘ └──┘     └┘ 
par    └───┘ └──┘     └┘ 
pid    └───┘ └──┘     └┘ 
st   ────────────────────────┘└─
1095    filter_upwards [h, hs],
src    └──────────────┘ └┘  
typ    └──────────────┘ └┘  
doc    └──────────────┘ └┘  
txt    └──────────────┘ └┘  
par    └──────────────┘ └┘  
pid                  └┘ └┘  
st   ───────────────────────┘└─
1096    simp only [subset_def, mem_preimage, mem_set_of_eq, forall_true_iff] {contextual := tt}
id                └────────┘  └──────────┘  └───────────┘  └─────────────┘                 └┘
src    └─────────┘└────────┘└┘└──────────┘└┘└───────────┘└┘└─────────────┘└┘ └────────────┘└┘└┘
typ    └─────────┘└────────┘└┘└──────────┘└┘└───────────┘└┘└─────────────┘└┘ └────────────┘└┘└┘
doc    └─────────┘          └┘            └┘             └┘               └┘ └────────────┘  └┘
txt    └─────────┘          └┘            └┘             └┘               └┘ └────────────┘  └┘
par    └─────────┘          └┘            └┘             └┘               └┘ └────────────┘  └┘
pid        └──┘└┘          └┘            └┘             └┘                └────────────┘  
st   ─────────────────────────────────────────────────────────────────────────────────────────┘
1097  end,
st   └─┘
1098  le_antisymm (this m₁ m₂ h) (this m₂ m₁ $ mem_sets_of_superset h $ assume x, eq.symm)
id   └─────────┘  └──┘ └┘ └┘    └──┘ └┘ └┘   └──────────────────┘             └─────┘
src  └─────────┘                              └──────────────────┘               └─────┘
typ  └─────────┘  └──┘ └┘ └┘    └──┘ └┘ └┘   └──────────────────┘             └─────┘
1099  
1100  -- this is a generic rule for monotone functions:
1101  lemma map_infi_le {f : ι → filter α} {m : α → β} :
id                             └────┘           
src                             └────┘
typ                            └────┘           
1102    map m (infi f) ≤ (⨅ i, map m (f i)) :=
id     └─┘   └──┘       └─┘    
src    └─┘    └──┘         └─┘
typ    └─┘   └──┘       └─┘    
doc    └─┘    └──┘          └─┘
1103  le_infi $ assume i, map_mono $ infi_le _ _
id   └─────┘            └──────┘   └─────┘
src  └─────┘             └──────┘   └─────┘
typ  └─────┘            └──────┘   └─────┘
1104  
1105  lemma map_infi_eq {f : ι → filter α} {m : α → β} (hf : directed (≥) f) (hι : nonempty ι) :
id                             └────┘                   └──────┘            └──────┘ 
src                             └────┘                      └──────┘             └──────┘
typ                            └────┘                   └──────┘            └──────┘ 
doc                                                         └──────┘
1106    map m (infi f) = (⨅ i, map m (f i)) :=
id     └─┘   └──┘       └─┘    
src    └─┘    └──┘         └─┘
typ    └─┘   └──┘       └─┘    
doc    └─┘    └──┘          └─┘
1107  le_antisymm
id   └─────────┘
src  └─────────┘
typ  └─────────┘
1108    map_infi_le
id     └─────────┘
src    └─────────┘
typ    └─────────┘
1109    (assume s (hs : preimage m s ∈ infi f),
id                    └──────┘    └──┘ 
src                    └──────┘      └──┘
typ                   └──────┘    └──┘ 
doc                    └──────┘       └──┘
1110      have ∃i, preimage m s ∈ f i,
id             └──────┘     
src             └──────┘     
typ            └──────┘     
doc               └──────┘
1111        by simp only [infi_sets_eq hf hι, mem_Union] at hs; assumption,
id                       └──────────┘ └┘ └┘  └───────┘
src           └─────────┘└──────────┘    └┘└───────┘└─────┘  └────────┘
typ           └─────────┘└──────────┘└┘└┘└┘└───────┘└─────┘  └────────┘
doc           └─────────┘                └┘         └─────┘  └────────┘
txt           └─────────┘                └┘         └─────┘  └────────┘
par           └─────────┘                └┘         └─────┘  └────────┘
pid               └──┘└┘                └┘         └───┘
st           └──────────────────────────────────────────────────────────┘
1112      let ⟨i, hi⟩ := this in
id       └─┘           └──┘
typ      └─┘           └──┘
1113      have (⨅ i, map m (f i)) ≤ principal s, from
id               └─┘        └───────┘ 
src               └─┘           └───────┘
typ              └─┘        └───────┘ 
doc               └─┘            └───────┘
1114        infi_le_of_le i $ by simp only [le_principal_iff, mem_map]; assumption,
id         └───────────┘                   └──────────────┘  └─────┘
src        └───────────┘        └─────────┘└──────────────┘└┘└─────┘  └────────┘
typ        └───────────┘        └─────────┘└──────────────┘└┘└─────┘  └────────┘
doc                             └─────────┘                └┘         └────────┘
txt                             └─────────┘                └┘         └────────┘
par                             └─────────┘                └┘         └────────┘
pid                                 └──┘└┘                └┘       
st                             └────────────────────────────────────────────────┘
1115      by simp only [filter.le_principal_iff] at this; assumption)
id                     └─────────────────────┘
src         └─────────┘└─────────────────────┘└───────┘  └────────┘
typ         └─────────┘└─────────────────────┘└───────┘  └────────┘
doc         └─────────┘                       └───────┘  └────────┘
txt         └─────────┘                       └───────┘  └────────┘
par         └─────────┘                       └───────┘  └────────┘
pid             └──┘└┘                       └─────┘
st         └──────────────────────────────────────────────────────┘
1116  
1117  lemma map_binfi_eq {ι : Type w} {f : ι → filter α} {m : α → β} {p : ι → Prop}
id                                           └────┘                  
src                                           └────┘
typ                                          └────┘                  
1118    (h : directed_on (f ⁻¹'o (≥)) {x | p x}) (ne : ∃i, p i) :
id          └─────────┘   └──┘                    
src         └─────────┘    └──┘                      
typ         └─────────┘   └──┘                    
doc         └─────────┘    └──┘
1119    map m (⨅i (h : p i), f i) = (⨅i (h: p i), map m (f i)) :=
id     └─┘                         └─┘    
src    └─┘                                  └─┘
typ    └─┘                         └─┘    
doc    └─┘                                   └─┘
1120  let ⟨i, hi⟩ := ne in
id   └─┘    └┘     └┘
src                 └┘
typ  └─┘    └┘     └┘
1121  calc map m (⨅i (h : p i), f i) = map m (⨅i:subtype p, f i.val) : by simp only [infi_subtype, eq_self_iff_true]
id        └─┘                 └─┘     └─────┘   └──┘                  └──────────┘  └──────────────┘
src       └─┘                       └─┘      └─────┘      └──┘       └─────────┘└──────────┘└┘└──────────────┘└─
typ       └─┘                 └─┘     └─────┘   └──┘       └─────────┘└──────────┘└┘└──────────────┘└─
doc       └─┘                       └─┘                              └─────────┘            └┘                └─
txt                                                                      └─────────┘            └┘                └─
par                                                                      └─────────┘            └┘                └─
pid                                                                          └──┘└┘            └┘                
st                                                                      └───────────────────────────────────────────
1122    ... = (⨅i:subtype p, map m (f i.val)) : map_infi_eq
id              └─────┘  └─┘    └──┘     └─────────┘
src  ─┘         └─────┘   └─┘       └──┘     └─────────┘
typ  ─┘         └─────┘  └─┘    └──┘     └─────────┘
doc  ─┘                   └─┘
txt  ─┘
par  ─┘
pid  ─┘
st   ─┘
1123      (assume ⟨x, hx⟩ ⟨y, hy⟩, match h x hx y hy with ⟨z, h₁, h₂, h₃⟩ := ⟨⟨z, h₁⟩, h₂, h₃⟩ end)
id                 └┘    └┘                            └┘  └┘  └┘
typ                └┘    └┘                            └┘  └┘  └┘
1124      ⟨⟨i, hi⟩⟩
1125    ... = (⨅i (h : p i), map m (f i)) : by simp only [infi_subtype, eq_self_iff_true]
id                     └─┘                       └──────────┘  └──────────────┘
src                       └─┘               └─────────┘└──────────┘└┘└──────────────┘└─
typ                    └─┘            └─────────┘└──────────┘└┘└──────────────┘└─
doc                       └─┘               └─────────┘            └┘                └─
txt                                           └─────────┘            └┘                └─
par                                           └─────────┘            └┘                └─
pid                                               └──┘└┘            └┘                
st                                           └───────────────────────────────────────────
1126  
src  
typ  
doc  
txt  
par  
pid  
st   
1127  lemma map_inf_le {f g : filter α} {m : α → β} : map m (f ⊓ g) ≤ map m f ⊓ map m g :=
id                           └────┘               └─┘        └─┘    └─┘  
src                          └────┘                  └─┘           └─┘      └─┘
typ                          └────┘               └─┘        └─┘    └─┘  
doc                                                  └─┘             └─┘       └─┘
1128  (@map_mono _ _ m).map_inf_le f g
id     └──────┘      └────────┘   
src    └──────┘       └────────┘
typ    └──────┘      └────────┘   
1129  
1130  lemma map_inf' {f g : filter α} {m : α → β} {t : set α} (htf : t ∈ f) (htg : t ∈ g)
id                         └────┘                  └─┘                       
src                        └────┘                     └─┘                          
typ                        └────┘                  └─┘                       
1131    (h : ∀x∈t, ∀y∈t, m x = m y → x = y) : map m (f ⊓ g) = map m f ⊓ map m g :=
id                               └─┘        └─┘    └─┘  
src                                        └─┘           └─┘      └─┘
typ                              └─┘        └─┘    └─┘  
doc                                          └─┘             └─┘       └─┘
1132  begin
st   └─────
1133    refine le_antisymm map_inf_le (assume s hs, _),
id            └─────────┘ └────────┘
src    └─────┘└─────────┘└────────┘       └───────┘
typ    └─────┘└─────────┘└────────┘       └───────┘
doc    └─────┘                            └───────┘
txt    └─────┘                            └───────┘
par    └─────┘                            └───────┘
pid                                      └───────┘
st   ───────────────────────────────────────────────┘└─
1134    simp only [map, mem_inf_sets, exists_prop, mem_map, mem_preimage, mem_inf_sets] at hs ⊢,
id                └─┘  └──────────┘  └─────────┘  └─────┘  └──────────┘  └──────────┘
src    └─────────┘└─┘└┘└──────────┘└┘└─────────┘└┘└─────┘└┘└──────────┘└┘└──────────┘└───────┘
typ    └─────────┘└─┘└┘└──────────┘└┘└─────────┘└┘└─────┘└┘└──────────┘└┘└──────────┘└───────┘
doc    └─────────┘└─┘└┘            └┘           └┘       └┘            └┘            └───────┘
txt    └─────────┘   └┘            └┘           └┘       └┘            └┘            └───────┘
par    └─────────┘   └┘            └┘           └┘       └┘            └┘            └───────┘
pid        └──┘└┘   └┘            └┘           └┘       └┘            └┘            └─────┘
st   ────────────────────────────────────────────────────────────────────────────────────────┘└─
1135    rcases hs with ⟨t₁, h₁, t₂, h₂, hs⟩,
id            └┘
src    └─────┘  └────────────────────────┘
typ    └─────┘└┘└────────────────────────┘
doc    └─────┘  └────────────────────────┘
txt    └─────┘  └────────────────────────┘
par    └─────┘  └────────────────────────┘
pid            └────────────────────────┘
st   ────────────────────────────────────┘└─
1136    refine ⟨m '' (t₁ ∩ t), _, m '' (t₂ ∩ t), _, _⟩,
id               └┘  └┘              └┘   
src    └─────┘  └┘    └────┘        └──────┘
typ    └─────┘  └┘ └┘ └────┘   └┘ └──────┘
doc    └─────┘         └────┘        └──────┘
txt    └─────┘         └────┘        └──────┘
par    └─────┘         └────┘        └──────┘
pid                   └────┘        └──────┘
st   ───────────────────────────────────────────────┘└─
1137    { filter_upwards [h₁, htf] assume a h₁ h₂, mem_image_of_mem _ ⟨h₁, h₂⟩ },
id                                                └──────────────┘
src      └──────────────┘  └┘   └┘      └────────┘└──────────────┘└─┘   └┘  └┘
typ      └──────────────┘  └┘   └┘      └────────┘└──────────────┘└─┘   └┘  └┘
doc      └──────────────┘  └┘   └┘      └────────┘                └─┘   └┘  └┘
txt      └──────────────┘  └┘   └┘      └────────┘                └─┘   └┘  └┘
par      └──────────────┘  └┘   └┘      └────────┘                └─┘   └┘  └┘
pid                    └┘  └┘         └────────┘                └─┘   └┘  
st   ───┘└───────────────────────────────────────────────────────────────────┘└┘
1138    { filter_upwards [h₂, htg] assume a h₁ h₂, mem_image_of_mem _ ⟨h₁, h₂⟩ },
id                                                └──────────────┘
src      └──────────────┘  └┘   └┘      └────────┘└──────────────┘└─┘   └┘  └┘
typ      └──────────────┘  └┘   └┘      └────────┘└──────────────┘└─┘   └┘  └┘
doc      └──────────────┘  └┘   └┘      └────────┘                └─┘   └┘  └┘
txt      └──────────────┘  └┘   └┘      └────────┘                └─┘   └┘  └┘
par      └──────────────┘  └┘   └┘      └────────┘                └─┘   └┘  └┘
pid                    └┘  └┘         └────────┘                └─┘   └┘  
st   ───┘└───────────────────────────────────────────────────────────────────┘└┘
1139    { rw [image_inter_on],
id           └────────────┘
src      └──┘└────────────┘
typ      └──┘└────────────┘
doc      └──┘              
txt      └──┘              
par      └──┘              
pid        └┘              
st   ─────────────────────┘└──
1140      { refine image_subset_iff.2 _,
id                └──────────────┘
src        └─────┘└──────────────┘└──┘
typ        └─────┘└──────────────┘└──┘
doc        └─────┘└──────────────┘└──┘
txt        └─────┘                └──┘
par        └─────┘                └──┘
pid                              └──┘
st   ─────┘└─────────────────────────┘└─
1141        exact λ x ⟨⟨h₁, _⟩, h₂, _⟩, hs ⟨h₁, h₂⟩ },
id                     └┘      └┘      └┘
src        └────┘ └──┘   └────┘  └────┘     └┘  └┘
typ        └────┘ └──┘ └┘└────┘└┘└────┘└┘   └┘  └┘
doc        └────┘ └──┘   └────┘  └────┘     └┘  └┘
txt        └────┘ └──┘   └────┘  └────┘     └┘  └┘
par        └────┘ └──┘   └────┘  └────┘     └┘  └┘
pid              └──┘   └────┘  └────┘     └┘  
st   ─────────────────────────────────────────────┘└┘
1142      { exact λ x ⟨_, hx⟩ y ⟨_, hy⟩, h x hx y hy } }
id                       └┘        └┘   
src        └────┘ └─────┘  └──────┘  └─┘       
typ        └────┘ └─────┘└┘└──────┘└┘└─┘      
doc        └────┘ └─────┘  └──────┘  └─┘       
txt        └────┘ └─────┘  └──────┘  └─┘       
par        └────┘ └─────┘  └──────┘  └─┘       
pid              └─────┘  └──────┘  └─┘       
st   ──────────────────────────────────────────────┘└───
1143  end
st   ──┘
1144  
1145  lemma map_inf {f g : filter α} {m : α → β} (h : function.injective m) :
id                        └────┘                  └────────────────┘ 
src                       └────┘                     └────────────────┘
typ                       └────┘                  └────────────────┘ 
1146    map m (f ⊓ g) = map m f ⊓ map m g :=
id     └─┘        └─┘    └─┘  
src    └─┘           └─┘      └─┘
typ    └─┘        └─┘    └─┘  
doc    └─┘             └─┘       └─┘
1147  map_inf' univ_mem_sets univ_mem_sets (assume x _ y _ hxy, h hxy)
id   └──────┘ └───────────┘ └───────────┘             └─┘   └─┘
src  └──────┘ └───────────┘ └───────────┘
typ  └──────┘ └───────────┘ └───────────┘             └─┘   └─┘
1148  
1149  lemma map_eq_comap_of_inverse {f : filter α} {m : α → β} {n : β → α}
id                                      └────┘                     
src                                     └────┘
typ                                     └────┘                     
1150    (h₁ : m ∘ n = id) (h₂ : n ∘ m = id) : map m f = comap n f :=
id               └┘            └┘    └─┘    └───┘  
src                └┘              └┘    └─┘      └───┘
typ              └┘            └┘    └─┘    └───┘  
doc                                          └─┘       └───┘
1151  le_antisymm
id   └─────────┘
src  └─────────┘
typ  └─────────┘
1152    (assume b ⟨a, ha, (h : preimage n a ⊆ b)⟩, f.sets_of_superset ha $
id                └┘      └──────┘         └───────────────┘
src                           └──────┘            └───────────────┘
typ               └┘      └──────┘         └───────────────┘
doc                           └──────┘
1153      calc a = preimage (n ∘ m) a : by simp only [h₂, preimage_id, eq_self_iff_true]
id                └──────┘                        └┘  └─────────┘  └──────────────┘
src               └──────┘               └─────────┘  └┘└─────────┘└┘└──────────────┘└─
typ               └──────┘             └─────────┘└┘└┘└─────────┘└┘└──────────────┘└─
doc               └──────┘                └─────────┘  └┘           └┘                └─
txt                                       └─────────┘  └┘           └┘                └─
par                                       └─────────┘  └┘           └┘                └─
pid                                           └──┘└┘  └┘           └┘                
st                                       └──────────────────────────────────────────────
1154        ... ⊆ preimage m b : preimage_mono h)
id               └──────┘     └───────────┘
src  ─────┘      └──────┘       └───────────┘
typ  ─────┘      └──────┘     └───────────┘
doc  ─────┘      └──────┘
txt  ─────┘
par  ─────┘
pid  ─────┘
st   ─────┘
1155    (assume b (hb : preimage m b ∈ f),
id                    └──────┘    
src                    └──────┘     
typ                   └──────┘    
doc                    └──────┘
1156      ⟨preimage m b, hb, show preimage (m ∘ n) b ⊆ b, by simp only [h₁]; apply subset.refl⟩)
id        └──────┘    └┘       └──────┘                        └┘         └─────────┘
src       └──────┘               └──────┘                 └─────────┘    └────┘└─────────┘
typ       └──────┘    └┘       └──────┘             └─────────┘└┘  └────┘└─────────┘
doc       └──────┘               └──────┘                   └─────────┘    └────┘
txt                                                         └─────────┘    └────┘
par                                                         └─────────┘    └────┘
pid                                                             └──┘└┘         
st                                                         └────────────────────────────────┘
1157  
1158  lemma map_swap_eq_comap_swap {f : filter (α × β)} : prod.swap <$> f = comap prod.swap f :=
id                                     └────┘         └───────┘ └─┘   └───┘ └───────┘ 
src                                    └────┘           └───────┘ └─┘    └───┘ └───────┘
typ                                    └────┘         └───────┘ └─┘   └───┘ └───────┘ 
doc                                                      └───────┘         └───┘ └───────┘
1159  map_eq_comap_of_inverse prod.swap_swap_eq prod.swap_swap_eq
id   └─────────────────────┘ └───────────────┘ └───────────────┘
src  └─────────────────────┘ └───────────────┘ └───────────────┘
typ  └─────────────────────┘ └───────────────┘ └───────────────┘
1160  
1161  lemma le_map {f : filter α} {m : α → β} {g : filter β} (h : ∀s∈ f, m '' s ∈ g) :
id                     └────┘                  └────┘              └┘   
src                    └────┘                     └────┘                  └┘   
typ                    └────┘                  └────┘              └┘   
1162    g ≤ f.map m :=
id       └──┘ 
src        └──┘
typ      └──┘ 
doc         └──┘
1163  assume s hs, mem_sets_of_superset (h _ hs) $ image_preimage_subset _ _
id           └┘  └──────────────────┘     └┘    └───────────────────┘
src               └──────────────────┘            └───────────────────┘
typ          └┘  └──────────────────┘     └┘    └───────────────────┘
1164  
1165  section applicative
1166  
1167  lemma singleton_mem_pure_sets {a : α} : {a} ∈ (pure a : filter α) :=
id                                              └──┘    └────┘ 
src                                               └──┘     └────┘
typ                                             └──┘    └────┘ 
1168  mem_singleton a
id   └───────────┘ 
src  └───────────┘
typ  └───────────┘ 
1169  
1170  lemma pure_inj : function.injective (pure : α → filter α) :=
id                    └────────────────┘  └──┘      └────┘ 
src                   └────────────────┘  └──┘       └────┘
typ                   └────────────────┘  └──┘      └────┘ 
1171  assume a b hab, (filter.ext_iff.1 hab {x | a = x}).1 rfl
id            └─┘   └────────────┘  └─┘          └─┘
src                   └────────────┘                  └─┘
typ           └─┘   └────────────┘  └─┘          └─┘
1172  
1173  @[simp] lemma pure_ne_bot {α : Type u} {a : α} : pure a ≠ (⊥ : filter α) :=
id                                                   └──┘       └────┘ 
src                                                   └──┘        └────┘
typ                                                  └──┘       └────┘ 
doc    └──┘
1174  mt empty_in_sets_eq_bot.2 $ not_mem_empty a
id   └┘ └──────────────────┘    └───────────┘ 
src  └┘ └──────────────────┘    └───────────┘
typ  └┘ └──────────────────┘    └───────────┘ 
1175  
1176  @[simp] lemma le_pure_iff {f : filter α} {a : α} : f ≤ pure a ↔ {a} ∈ f :=
id                                  └────┘              └──┘      
src                                 └────┘                 └──┘       
typ                                 └────┘              └──┘      
doc    └──┘
1177  ⟨λ h, h singleton_mem_pure_sets,
id         └─────────────────────┘
src          └─────────────────────┘
typ        └─────────────────────┘
1178    λ h s hs, mem_sets_of_superset h $ singleton_subset_iff.2 hs⟩
id         └┘  └──────────────────┘    └──────────────────┘  └┘
src              └──────────────────┘     └──────────────────┘
typ        └┘  └──────────────────┘    └──────────────────┘  └┘
1179  
1180  lemma mem_seq_sets_def {f : filter (α → β)} {g : filter α} {s : set β} :
id                               └────┘             └────┘        └─┘ 
src                              └────┘               └────┘         └─┘
typ                              └────┘             └────┘        └─┘ 
1181    s ∈ f.seq g ↔ (∃u ∈ f, ∃t ∈ g, ∀x∈u, ∀y∈t, (x : α → β) y ∈ s) :=
id       └──┘                               
src        └──┘                                           
typ      └──┘                               
doc         └──┘
1182  iff.rfl
id   └─────┘
src  └─────┘
typ  └─────┘
1183  
1184  lemma mem_seq_sets_iff {f : filter (α → β)} {g : filter α} {s : set β} :
id                               └────┘             └────┘        └─┘ 
src                              └────┘               └────┘         └─┘
typ                              └────┘             └────┘        └─┘ 
1185    s ∈ f.seq g ↔ (∃u ∈ f, ∃t ∈ g, set.seq u t ⊆ s) :=
id       └──┘            └─────┘    
src        └──┘                 └─────┘     
typ      └──┘            └─────┘    
doc         └──┘
1186  by simp only [mem_seq_sets_def, seq_subset, exists_prop, iff_self]
id                 └──────────────┘  └────────┘  └─────────┘  └──────┘
src     └─────────┘└──────────────┘└┘└────────┘└┘└─────────┘└┘└──────┘└─
typ     └─────────┘└──────────────┘└┘└────────┘└┘└─────────┘└┘└──────┘└─
doc     └─────────┘                └┘          └┘           └┘        └─
txt     └─────────┘                └┘          └┘           └┘        └─
par     └─────────┘                └┘          └┘           └┘        └─
pid         └──┘└┘                └┘          └┘           └┘        
st     └────────────────────────────────────────────────────────────────
1187  
src  
typ  
doc  
txt  
par  
pid  
st   
1188  lemma mem_map_seq_iff {f : filter α} {g : filter β} {m : α → β → γ} {s : set γ} :
id                              └────┘        └────┘                     └─┘ 
src                             └────┘         └────┘                         └─┘
typ                             └────┘        └────┘                     └─┘ 
1189    s ∈ (f.map m).seq g ↔ (∃t u, t ∈ g ∧ u ∈ f ∧ ∀x∈u, ∀y∈t, m x y ∈ s) :=
id        └──┘  └─┘                           
src         └──┘   └─┘                                        
typ       └──┘  └─┘                           
doc          └──┘   └─┘
1190  iff.intro
id   └───────┘
src  └───────┘
typ  └───────┘
1191    (assume ⟨t, ht, s, hs, hts⟩, ⟨s, m ⁻¹' t, hs, ht, assume a, hts _⟩)
id               └┘    └┘  └─┘        └─┘                   
src                                       └─┘
typ              └┘    └┘  └─┘        └─┘                   
doc                                       └─┘
1192    (assume ⟨t, s, ht, hs, hts⟩, ⟨m '' s, image_mem_map hs, t, ht, assume f ⟨a, has, eq⟩, eq ▸ hts _ has⟩)
id                 └┘  └┘  └─┘     └┘    └───────────┘                       └─┘  └┘      
src                                    └┘    └───────────┘                              └┘      
typ                └┘  └┘  └─┘     └┘    └───────────┘                       └─┘  └┘      
1193  
1194  lemma seq_mem_seq_sets {f : filter (α → β)} {g : filter α} {s : set (α → β)} {t : set α}
id                               └────┘             └────┘        └─┘             └─┘ 
src                              └────┘               └────┘         └─┘               └─┘
typ                              └────┘             └────┘        └─┘             └─┘ 
1195    (hs : s ∈ f) (ht : t ∈ g) : s.seq t ∈ f.seq g :=
id                           └──┘   └──┘ 
src                               └──┘     └──┘
typ                          └──┘   └──┘ 
doc                                           └──┘
1196  ⟨s, hs, t, ht, assume f hf a ha, ⟨f, hf, a, ha, rfl⟩⟩
id      └┘    └┘          └┘  └┘     └┘    └┘  └─┘
src                                                  └─┘
typ     └┘    └┘          └┘  └┘     └┘    └┘  └─┘
1197  
1198  lemma le_seq {f : filter (α → β)} {g : filter α} {h : filter β}
id                     └────┘             └────┘        └────┘ 
src                    └────┘               └────┘         └────┘
typ                    └────┘             └────┘        └────┘ 
1199    (hh : ∀t ∈ f, ∀u ∈ g, set.seq t u ∈ h) : h ≤ seq f g :=
id                       └─────┘          └─┘  
src                          └─────┘              └─┘
typ                      └─────┘          └─┘  
doc                                                 └─┘
1200  assume s ⟨t, ht, u, hu, hs⟩, mem_sets_of_superset (hh _ ht _ hu) $
id              └┘     └┘  └┘   └──────────────────┘  └┘
src                               └──────────────────┘
typ             └┘     └┘  └┘   └──────────────────┘  └┘
1201    assume b ⟨m, hm, a, ha, eq⟩, eq ▸ hs _ hm _ ha
id                └┘     └┘  └┘      
src                            └┘      
typ               └┘     └┘  └┘      
1202  
1203  lemma seq_mono {f₁ f₂ : filter (α → β)} {g₁ g₂ : filter α}
id                           └────┘                 └────┘ 
src                          └────┘                   └────┘
typ                          └────┘                 └────┘ 
1204    (hf : f₁ ≤ f₂) (hg : g₁ ≤ g₂) : f₁.seq g₁ ≤ f₂.seq g₂ :=
id           └┘  └┘        └┘  └┘    └┘└──┘ └┘  └┘└──┘ └┘
src                                    └──┘       └──┘
typ          └┘  └┘        └┘  └┘    └┘└──┘ └┘  └┘└──┘ └┘
doc                                      └──┘        └──┘
1205  le_seq $ assume s hs t ht, seq_mem_seq_sets (hf hs) (hg ht)
id   └────┘           └┘  └┘  └──────────────┘  └┘ └┘   └┘ └┘
src  └────┘                     └──────────────┘
typ  └────┘           └┘  └┘  └──────────────┘  └┘ └┘   └┘ └┘
1206  
1207  @[simp] lemma pure_seq_eq_map (g : α → β) (f : filter α) : seq (pure g) f = f.map g :=
id                                                └────┘     └─┘  └──┘     └──┘ 
src                                                 └────┘      └─┘  └──┘        └──┘
typ                                               └────┘     └─┘  └──┘     └──┘ 
doc    └──┘                                                     └─┘               └──┘
1208  begin
st   └─────
1209    refine le_antisymm  (le_map $ assume s hs, _) (le_seq $ assume s hs t ht, _),
id            └─────────┘   └────┘                    └────┘
src    └─────┘└─────────┘└┘ └────┘       └────────┘ └────┘       └────────────┘
typ    └─────┘└─────────┘└┘ └────┘       └────────┘ └────┘       └────────────┘
doc    └─────┘           └┘              └────────┘              └────────────┘
txt    └─────┘           └┘              └────────┘              └────────────┘
par    └─────┘           └┘              └────────┘              └────────────┘
pid                     └┘              └────────┘              └────────────┘
st   ─────────────────────────────────────────────────────────────────────────────┘└─
1210    { rw ← singleton_seq, apply seq_mem_seq_sets _ hs,
id            └───────────┘        └──────────────┘   └┘
src      └───┘└───────────┘  └────┘└──────────────┘└─┘
typ      └───┘└───────────┘  └────┘└──────────────┘└─┘└┘
doc      └───┘               └────┘                └─┘
txt      └───┘               └────┘                └─┘
par      └───┘               └────┘                └─┘
pid        └─┘                                    └─┘
st   ───┘└────────────────┘└───────────────────────────┘└─
1211      exact singleton_mem_pure_sets },
id             └─────────────────────┘
src      └────┘└─────────────────────┘
typ      └────┘└─────────────────────┘
doc      └────┘                       
txt      └────┘                       
par      └────┘                       
pid                                  
st   ─────────────────────────────────┘└┘
1212    { refine sets_of_superset (map g f) (image_mem_map ht) _,
id              └──────────────┘  └─┘     └───────────┘ └┘
src      └─────┘└──────────────┘ └─┘  └┘ └───────────┘  └─┘
typ      └─────┘└──────────────┘ └─┘└┘ └───────────┘└┘└─┘
doc      └─────┘                 └─┘  └┘                └─┘
txt      └─────┘                      └┘                └─┘
par      └─────┘                      └┘                └─┘
pid                                  └┘                └─┘
st   ─────────────────────────────────────────────────────────┘└─
1213      rintros b ⟨a, ha, rfl⟩, exact ⟨g, hs, a, ha, rfl⟩ }
id                                        └┘    └┘  └─┘
src      └────────────────────┘  └────┘  └┘  └┘ └┘  └┘└─┘└┘
typ      └────────────────────┘  └────┘ └┘└┘└┘└┘└┘└┘└─┘└┘
doc      └────────────────────┘  └────┘  └┘  └┘ └┘  └┘   └┘
txt      └────────────────────┘  └────┘  └┘  └┘ └┘  └┘   └┘
par      └────────────────────┘  └────┘  └┘  └┘ └┘  └┘   └┘
pid             └─────────────┘         └┘  └┘ └┘  └┘   
st   ─────────────────────────┘└──────────────────────────┘└─
1214  end
st   ──┘
1215  
1216  @[simp] lemma seq_pure (f : filter (α → β)) (a : α) : seq f (pure a) = map (λg:α → β, g a) f :=
id                               └────┘                └─┘   └──┘    └─┘            
src                              └────┘                    └─┘    └──┘     └─┘
typ                              └────┘                └─┘   └──┘    └─┘            
doc    └──┘                                                └─┘              └─┘
1217  begin
st   └─────
1218    refine le_antisymm (le_map $ assume s hs, _) (le_seq $ assume s hs t ht, _),
id            └─────────┘  └────┘                    └────┘
src    └─────┘└─────────┘ └────┘       └────────┘ └────┘       └────────────┘
typ    └─────┘└─────────┘ └────┘       └────────┘ └────┘       └────────────┘
doc    └─────┘                         └────────┘              └────────────┘
txt    └─────┘                         └────────┘              └────────────┘
par    └─────┘                         └────────┘              └────────────┘
pid                                   └────────┘              └────────────┘
st   ────────────────────────────────────────────────────────────────────────────┘└─
1219    { rw ← seq_singleton,
id            └───────────┘
src      └───┘└───────────┘
typ      └───┘└───────────┘
doc      └───┘
txt      └───┘
par      └───┘
pid        └─┘
st   ───┘└────────────────┘└─
1220      exact seq_mem_seq_sets hs singleton_mem_pure_sets },
id             └──────────────┘ └┘ └─────────────────────┘
src      └────┘└──────────────┘  └─────────────────────┘
typ      └────┘└──────────────┘└┘└─────────────────────┘
doc      └────┘                                         
txt      └────┘                                         
par      └────┘                                         
pid                                                    
st   ─────────────────────────────────────────────────────┘└┘
1221    { refine sets_of_superset (map (λg:α→β, g a) f) (image_mem_map hs) _,
id              └──────────────┘  └─┘               └───────────┘ └┘
src      └─────┘└──────────────┘ └─┘  └┘   └┘  └┘ └┘ └───────────┘  └─┘
typ      └─────┘└──────────────┘ └─┘  └┘ └┘ └┘└┘ └───────────┘└┘└─┘
doc      └─────┘                 └─┘  └┘   └┘  └┘ └┘                └─┘
txt      └─────┘                      └┘   └┘  └┘ └┘                └─┘
par      └─────┘                      └┘   └┘  └┘ └┘                └─┘
pid                                  └┘   └┘  └┘ └┘                └─┘
st   ─────────────────────────────────────────────────────────────────────┘└─
1222      rintros b ⟨g, hg, rfl⟩, exact ⟨g, hg, a, ht, rfl⟩ }
id                                        └┘    └┘  └─┘
src      └────────────────────┘  └────┘  └┘  └┘ └┘  └┘└─┘└┘
typ      └────────────────────┘  └────┘ └┘└┘└┘└┘└┘└┘└─┘└┘
doc      └────────────────────┘  └────┘  └┘  └┘ └┘  └┘   └┘
txt      └────────────────────┘  └────┘  └┘  └┘ └┘  └┘   └┘
par      └────────────────────┘  └────┘  └┘  └┘ └┘  └┘   └┘
pid             └─────────────┘         └┘  └┘ └┘  └┘   
st   ─────────────────────────┘└──────────────────────────┘└─
1223  end
st   ──┘
1224  
1225  @[simp] lemma seq_assoc (x : filter α) (g : filter (α → β)) (h : filter (β → γ)) :
id                                └────┘        └────┘             └────┘     
src                               └────┘         └────┘               └────┘
typ                               └────┘        └────┘             └────┘     
doc    └──┘
1226    seq h (seq g x) = seq (seq (map (∘) h) g) x :=
id     └─┘   └─┘     └─┘  └─┘  └─┘        
src    └─┘    └─┘       └─┘  └─┘  └─┘ 
typ    └─┘   └─┘     └─┘  └─┘  └─┘        
doc    └─┘    └─┘        └─┘  └─┘  └─┘
1227  begin
st   └─────
1228    refine le_antisymm (le_seq $ assume s hs t ht, _) (le_seq $ assume s hs t ht, _),
id            └─────────┘                                 └────┘
src    └─────┘└─────────┘              └─────────────┘ └────┘       └────────────┘
typ    └─────┘└─────────┘              └─────────────┘ └────┘       └────────────┘
doc    └─────┘                         └─────────────┘              └────────────┘
txt    └─────┘                         └─────────────┘              └────────────┘
par    └─────┘                         └─────────────┘              └────────────┘
pid                                   └─────────────┘              └────────────┘
st   ─────────────────────────────────────────────────────────────────────────────────┘└─
1229    { rcases mem_seq_sets_iff.1 hs with ⟨u, hu, v, hv, hs⟩,
id              └──────────────┘   └┘
src      └─────┘└──────────────┘└─┘  └──────────────────────┘
typ      └─────┘└──────────────┘└─┘└┘└──────────────────────┘
doc      └─────┘                └─┘  └──────────────────────┘
txt      └─────┘                └─┘  └──────────────────────┘
par      └─────┘                └─┘  └──────────────────────┘
pid                            └─┘  └──────────────────────┘
st   ───┘└──────────────────────────────────────────────────┘└─
1230      rcases mem_map_sets_iff.1 hu with ⟨w, hw, hu⟩,
id              └──────────────┘   └┘
src      └─────┘└──────────────┘└─┘  └───────────────┘
typ      └─────┘└──────────────┘└─┘└┘└───────────────┘
doc      └─────┘                └─┘  └───────────────┘
txt      └─────┘                └─┘  └───────────────┘
par      └─────┘                └─┘  └───────────────┘
pid                            └─┘  └───────────────┘
st   ────────────────────────────────────────────────┘└─
1231      refine mem_sets_of_superset _
id              └──────────────────┘
src      └─────┘└──────────────────┘└──
typ      └─────┘└──────────────────┘└──
doc      └─────┘                    └──
txt      └─────┘                    └──
par      └─────┘                    └──
pid                                └──
st   ──────────────────────────────────
1232        (set.seq_mono (subset.trans (set.seq_mono hu (subset.refl _)) hs) (subset.refl _)),
id                        └──────────┘  └──────────┘ └┘                  └┘   └─────────┘
src  ─────┘              └──────────┘ └──────────┘              └───┘  └┘ └─────────┘└──┘
typ  ─────┘              └──────────┘ └──────────┘└┘            └───┘└┘└┘ └─────────┘└──┘
doc  ─────┘                                                     └───┘  └┘            └──┘
txt  ─────┘                                                     └───┘  └┘            └──┘
par  ─────┘                                                     └───┘  └┘            └──┘
pid  ─────┘                                                     └───┘  └┘            └──┘
st   ───────────────────────────────────────────────────────────────────────────────────────┘└─
1233      rw ← set.seq_seq,
id            └─────────┘
src      └───┘└─────────┘
typ      └───┘└─────────┘
doc      └───┘
txt      └───┘
par      └───┘
pid        └─┘
st   ───────────────────┘└─
1234      exact seq_mem_seq_sets hw (seq_mem_seq_sets hv ht) },
id                              └┘  └──────────────┘ └┘ └┘
src      └────┘                   └──────────────┘    └┘
typ      └────┘                └┘ └──────────────┘└┘└┘└┘
doc      └────┘                                       └┘
txt      └────┘                                       └┘
par      └────┘                                       └┘
pid                                                  
st   ──────────────────────────────────────────────────────┘└┘
1235    { rcases mem_seq_sets_iff.1 ht with ⟨u, hu, v, hv, ht⟩,
id              └──────────────┘   └┘
src      └─────┘└──────────────┘└─┘  └──────────────────────┘
typ      └─────┘└──────────────┘└─┘└┘└──────────────────────┘
doc      └─────┘                └─┘  └──────────────────────┘
txt      └─────┘                └─┘  └──────────────────────┘
par      └─────┘                └─┘  └──────────────────────┘
pid                            └─┘  └──────────────────────┘
st   ───────────────────────────────────────────────────────┘└─
1236      refine mem_sets_of_superset _ (set.seq_mono (subset.refl _) ht),
id              └──────────────────┘    └──────────┘  └─────────┘    └┘
src      └─────┘└──────────────────┘└─┘ └──────────┘ └─────────┘└──┘  
typ      └─────┘└──────────────────┘└─┘ └──────────┘ └─────────┘└──┘└┘
doc      └─────┘                    └─┘                         └──┘  
txt      └─────┘                    └─┘                         └──┘  
par      └─────┘                    └─┘                         └──┘  
pid                                └─┘                         └──┘  
st   ──────────────────────────────────────────────────────────────────┘└─
1237      rw set.seq_seq,
id          └─────────┘
src      └─┘└─────────┘
typ      └─┘└─────────┘
doc      └─┘
txt      └─┘
par      └─┘
pid        
st   ─────────────────┘└─
1238      exact seq_mem_seq_sets (seq_mem_seq_sets (image_mem_map hs) hu) hv }
id                               └──────────────┘  └───────────┘ └┘  └┘  └┘
src      └────┘                 └──────────────┘ └───────────┘  └┘  └┘  
typ      └────┘                 └──────────────┘ └───────────┘└┘└┘└┘└┘└┘
doc      └────┘                                                 └┘  └┘  
txt      └────┘                                                 └┘  └┘  
par      └────┘                                                 └┘  └┘  
pid                                                            └┘  └┘  
st   ──────────────────────────────────────────────────────────────────────┘└─
1239  end
st   ──┘
1240  
1241  lemma prod_map_seq_comm (f : filter α) (g : filter β) :
id                                └────┘        └────┘ 
src                               └────┘         └────┘
typ                               └────┘        └────┘ 
1242    (map prod.mk f).seq g = seq (map (λb a, (a, b)) g) f :=
id      └─┘ └─────┘  └─┘    └─┘  └─┘             
src     └─┘ └─────┘   └─┘     └─┘  └─┘        
typ     └─┘ └─────┘  └─┘    └─┘  └─┘             
doc     └─┘           └─┘      └─┘  └─┘
1243  begin
st   └─────
1244    refine le_antisymm (le_seq $ assume s hs t ht, _) (le_seq $ assume s hs t ht, _),
id            └─────────┘                                 └────┘
src    └─────┘└─────────┘              └─────────────┘ └────┘       └────────────┘
typ    └─────┘└─────────┘              └─────────────┘ └────┘       └────────────┘
doc    └─────┘                         └─────────────┘              └────────────┘
txt    └─────┘                         └─────────────┘              └────────────┘
par    └─────┘                         └─────────────┘              └────────────┘
pid                                   └─────────────┘              └────────────┘
st   ─────────────────────────────────────────────────────────────────────────────────┘└─
1245    { rcases mem_map_sets_iff.1 hs with ⟨u, hu, hs⟩,
id              └──────────────┘   └┘
src      └─────┘└──────────────┘└─┘  └───────────────┘
typ      └─────┘└──────────────┘└─┘└┘└───────────────┘
doc      └─────┘                └─┘  └───────────────┘
txt      └─────┘                └─┘  └───────────────┘
par      └─────┘                └─┘  └───────────────┘
pid                            └─┘  └───────────────┘
st   ───┘└───────────────────────────────────────────┘└─
1246      refine mem_sets_of_superset _ (set.seq_mono hs (subset.refl _)),
id              └──────────────────┘    └──────────┘ └┘  └─────────┘
src      └─────┘└──────────────────┘└─┘ └──────────┘   └─────────┘└──┘
typ      └─────┘└──────────────────┘└─┘ └──────────┘└┘ └─────────┘└──┘
doc      └─────┘                    └─┘                           └──┘
txt      └─────┘                    └─┘                           └──┘
par      └─────┘                    └─┘                           └──┘
pid                                └─┘                           └──┘
st   ──────────────────────────────────────────────────────────────────┘└─
1247      rw ← set.prod_image_seq_comm,
id            └─────────────────────┘
src      └───┘└─────────────────────┘
typ      └───┘└─────────────────────┘
doc      └───┘
txt      └───┘
par      └───┘
pid        └─┘
st   ───────────────────────────────┘└─
1248      exact seq_mem_seq_sets (image_mem_map ht) hu },
id             └──────────────┘  └───────────┘ └┘  └┘
src      └────┘└──────────────┘ └───────────┘  └┘  
typ      └────┘└──────────────┘ └───────────┘└┘└┘└┘
doc      └────┘                                └┘  
txt      └────┘                                └┘  
par      └────┘                                └┘  
pid                                           └┘  
st   ────────────────────────────────────────────────┘└┘
1249    { rcases mem_map_sets_iff.1 hs with ⟨u, hu, hs⟩,
id              └──────────────┘   └┘
src      └─────┘└──────────────┘└─┘  └───────────────┘
typ      └─────┘└──────────────┘└─┘└┘└───────────────┘
doc      └─────┘                └─┘  └───────────────┘
txt      └─────┘                └─┘  └───────────────┘
par      └─────┘                └─┘  └───────────────┘
pid                            └─┘  └───────────────┘
st   ────────────────────────────────────────────────┘└─
1250      refine mem_sets_of_superset _ (set.seq_mono hs (subset.refl _)),
id              └──────────────────┘    └──────────┘ └┘  └─────────┘
src      └─────┘└──────────────────┘└─┘ └──────────┘   └─────────┘└──┘
typ      └─────┘└──────────────────┘└─┘ └──────────┘└┘ └─────────┘└──┘
doc      └─────┘                    └─┘                           └──┘
txt      └─────┘                    └─┘                           └──┘
par      └─────┘                    └─┘                           └──┘
pid                                └─┘                           └──┘
st   ──────────────────────────────────────────────────────────────────┘└─
1251      rw set.prod_image_seq_comm,
id          └─────────────────────┘
src      └─┘└─────────────────────┘
typ      └─┘└─────────────────────┘
doc      └─┘
txt      └─┘
par      └─┘
pid        
st   ─────────────────────────────┘└─
1252      exact seq_mem_seq_sets (image_mem_map ht) hu }
id             └──────────────┘  └───────────┘ └┘  └┘
src      └────┘└──────────────┘ └───────────┘  └┘  
typ      └────┘└──────────────┘ └───────────┘└┘└┘└┘
doc      └────┘                                └┘  
txt      └────┘                                └┘  
par      └────┘                                └┘  
pid                                           └┘  
st   ────────────────────────────────────────────────┘└─
1253  end
st   ──┘
1254  
1255  instance : is_lawful_functor (filter : Type u → Type u) :=
id              └───────────────┘  └────┘   └──┘
src             └───────────────┘  └────┘
typ             └───────────────┘  └────┘   └──┘
1256  { id_map   := assume α f, map_id,
id                          └────┘
src                           └────┘
typ                         └────┘
1257    comp_map := assume α β γ f g a, map_map.symm }
id                               └─────┘└───┘
src                                    └─────┘└───┘
typ                              └─────┘└───┘
1258  
1259  instance : is_lawful_applicative (filter : Type u → Type u) :=
id              └───────────────────┘  └────┘   └──┘
src             └───────────────────┘  └────┘
typ             └───────────────────┘  └────┘   └──┘
1260  { pure_seq_eq_map := assume α β, pure_seq_eq_map,
id                                 └─────────────┘
src                                  └─────────────┘
typ                                └─────────────┘
1261    map_pure        := assume α β, map_pure,
id                                  └──────┘
src                                   └──────┘
typ                                 └──────┘
1262    seq_pure        := assume α β, seq_pure,
id                                  └──────┘
src                                   └──────┘
typ                                 └──────┘
1263    seq_assoc       := assume α β γ, seq_assoc }
id                                   └───────┘
src                                     └───────┘
typ                                  └───────┘
1264  
1265  instance : is_comm_applicative (filter : Type u → Type u) :=
id              └─────────────────┘  └────┘   └──┘
src             └─────────────────┘  └────┘
typ             └─────────────────┘  └────┘   └──┘
1266  ⟨assume α β f g, prod_map_seq_comm f g⟩
id                └───────────────┘  
src                   └───────────────┘
typ               └───────────────┘  
1267  
1268  lemma {l} seq_eq_filter_seq {α β : Type l} (f : filter (α → β)) (g : filter α) :
id                                                   └────┘             └────┘ 
src                                                  └────┘               └────┘
typ                                                  └────┘             └────┘ 
1269    f <*> g = seq f g := rfl
id      └─┘   └─┘      └─┘
src      └─┘    └─┘        └─┘
typ     └─┘   └─┘      └─┘
doc              └─┘
1270  
1271  end applicative
1272  
1273  /- bind equations -/
1274  section bind
1275  @[simp] lemma mem_bind_sets {s : set β} {f : filter α} {m : α → filter β} :
id                                    └─┘        └────┘           └────┘ 
src                                   └─┘         └────┘             └────┘
typ                                   └─┘        └────┘           └────┘ 
doc    └──┘
1276    s ∈ bind f m ↔ ∃t ∈ f, ∀x ∈ t, s ∈ m x :=
id       └──┘                 
src       └──┘                      
typ      └──┘                 
doc        └──┘
1277  calc s ∈ bind f m ↔ {a | s ∈ m a} ∈ f : by simp only [bind, mem_map, iff_self, mem_join_sets, mem_set_of_eq]
id          └──┘                               └──┘  └─────┘  └──────┘  └───────────┘  └───────────┘
src          └──┘                           └─────────┘└──┘└┘└─────┘└┘└──────┘└┘└───────────┘└┘└───────────┘└─
typ         └──┘                    └─────────┘└──┘└┘└─────┘└┘└──────┘└┘└───────────┘└┘└───────────┘└─
doc           └──┘                              └─────────┘└──┘└┘       └┘        └┘             └┘             └─
txt                                             └─────────┘    └┘       └┘        └┘             └┘             └─
par                                             └─────────┘    └┘       └┘        └┘             └┘             └─
pid                                                 └──┘└┘    └┘       └┘        └┘             └┘             
st                                             └──────────────────────────────────────────────────────────────────
1278                       ... ↔ (∃t ∈ f, t ⊆ {a | s ∈ m a}) : exists_sets_subset_iff.symm
id                                                └────────────────────┘└───┘
src  ────────────────────┘                               └────────────────────┘└───┘
typ  ────────────────────┘                        └────────────────────┘└───┘
doc  ────────────────────┘
txt  ────────────────────┘
par  ────────────────────┘
pid  ────────────────────┘
st   ────────────────────┘
1279                       ... ↔ (∃t ∈ f, ∀x ∈ t, s ∈ m x) : iff.rfl
id                                                └─────┘
src                                                      └─────┘
typ                                               └─────┘
1280  
1281  lemma bind_mono {f : filter α} {g h : α → filter β} (h₁ : {a | g a ≤ h a} ∈ f) :
id                        └────┘             └────┘                   
src                       └────┘               └────┘                        
typ                       └────┘             └────┘                   
1282    bind f g ≤ bind f h :=
id     └──┘    └──┘  
src    └──┘      └──┘
typ    └──┘    └──┘  
doc    └──┘       └──┘
1283  assume x h₂, show (_ ∈ f), by filter_upwards [h₁, h₂] assume s gh' h', gh' h'
id           └┘           
src                               └──────────────┘  └┘  └┘      └─────────┘     
typ          └┘                 └──────────────┘  └┘  └┘      └─────────┘     
doc                                └──────────────┘  └┘  └┘      └─────────┘     
txt                                └──────────────┘  └┘  └┘      └─────────┘     
par                                └──────────────┘  └┘  └┘      └─────────┘     
pid                                              └┘  └┘        └─────────┘     
st                                └────────────────────────────────────────────────
1284  
src  
typ  
doc  
txt  
par  
pid  
st   
1285  lemma bind_sup {f g : filter α} {h : α → filter β} :
id                         └────┘           └────┘ 
src                        └────┘             └────┘
typ                        └────┘           └────┘ 
1286    bind (f ⊔ g) h = bind f h ⊔ bind g h :=
id     └──┘        └──┘    └──┘  
src    └──┘           └──┘      └──┘
typ    └──┘        └──┘    └──┘  
doc    └──┘             └──┘       └──┘
1287  by simp only [bind, sup_join, map_sup, eq_self_iff_true]
id                 └──┘  └──────┘  └─────┘  └──────────────┘
src     └─────────┘└──┘└┘└──────┘└┘└─────┘└┘└──────────────┘└─
typ     └─────────┘└──┘└┘└──────┘└┘└─────┘└┘└──────────────┘└─
doc     └─────────┘└──┘└┘        └┘       └┘                └─
txt     └─────────┘    └┘        └┘       └┘                └─
par     └─────────┘    └┘        └┘       └┘                └─
pid         └──┘└┘    └┘        └┘       └┘                
st     └──────────────────────────────────────────────────────
1288  
src  
typ  
doc  
txt  
par  
pid  
st   
1289  lemma bind_mono2 {f g : filter α} {h : α → filter β} (h₁ : f ≤ g) :
id                           └────┘           └────┘           
src                          └────┘             └────┘            
typ                          └────┘           └────┘           
1290    bind f h ≤ bind g h :=
id     └──┘    └──┘  
src    └──┘      └──┘
typ    └──┘    └──┘  
doc    └──┘       └──┘
1291  assume s h', h₁ h'
id           └┘  └┘ └┘
typ          └┘  └┘ └┘
1292  
1293  lemma principal_bind {s : set α} {f : α → filter β} :
id                             └─┘           └────┘ 
src                            └─┘             └────┘
typ                            └─┘           └────┘ 
1294    (bind (principal s) f) = (⨆x ∈ s, f x) :=
id      └──┘  └───────┘            
src     └──┘  └───────┘              
typ     └──┘  └───────┘            
doc     └──┘  └───────┘               
1295  show join (map f (principal s)) = (⨆x ∈ s, f x),
id        └──┘  └─┘   └───────┘           
src       └──┘  └─┘    └───────┘            
typ       └──┘  └─┘   └───────┘           
doc       └──┘  └─┘    └───────┘             
1296    by simp only [Sup_image, join_principal_eq_Sup, map_principal, eq_self_iff_true]
id                   └───────┘  └───────────────────┘  └───────────┘  └──────────────┘
src       └─────────┘└───────┘└┘└───────────────────┘└┘└───────────┘└┘└──────────────┘└─
typ       └─────────┘└───────┘└┘└───────────────────┘└┘└───────────┘└┘└──────────────┘└─
doc       └─────────┘         └┘                     └┘             └┘                └─
txt       └─────────┘         └┘                     └┘             └┘                └─
par       └─────────┘         └┘                     └┘             └┘                └─
pid           └──┘└┘         └┘                     └┘             └┘                
st       └──────────────────────────────────────────────────────────────────────────────
1297  
src  
typ  
doc  
txt  
par  
pid  
st   
1298  end bind
1299  
1300  /-- If `f : ι → filter α` is derected, `ι` is not empty, and `∀ i, f i ≠ ⊥`, then `infi f ≠ ⊥`.
1301  See also `infi_ne_bot_of_directed` for a version assuming `nonempty α` instead of `nonempty ι`. -/
1302  lemma infi_ne_bot_of_directed' {f : ι → filter α} (hn : nonempty ι)
id                                          └────┘         └──────┘ 
src                                          └────┘          └──────┘
typ                                         └────┘         └──────┘ 
1303    (hd : directed (≥) f) (hb : ∀i, f i ≠ ⊥) : (infi f) ≠ ⊥ :=
id           └──────┘                       └──┘    
src          └──────┘                           └──┘     
typ          └──────┘                       └──┘    
doc          └──────┘                              └──┘
1304  begin
st   └─────
1305    intro h,
src    └─────┘
typ    └─────┘
doc    └─────┘
txt    └─────┘
par    └─────┘
pid         └┘
st   ────────┘└─
1306    have he: ∅  ∈ (infi f), from h.symm ▸ (mem_bot_sets : ∅ ∈ (⊥ : filter α)),
id                  └──┘         └────┘   └──────────┘           └────┘ 
src    └───────┘└┘ └──┘   └───┘└────┘ └──────────┘└─┘   └─┘└────┘ └┘
typ    └───────┘└┘ └──┘  └───┘└────┘ └──────────┘└─┘   └─┘└────┘└┘
doc    └───────┘ └┘  └──┘   └───┘                    └─┘    └─┘       └┘
txt    └───────┘ └┘         └───┘                    └─┘    └─┘       └┘
par    └───────┘ └┘         └───┘                    └─┘    └─┘       └┘
pid    └─────┘└┘ └┘         └───┘                    └─┘    └─┘       └┘
st   ───────────────────────┘└─────────────────────────────────────────────────┘└─
1307    obtain ⟨i, hi⟩ : ∃i, ∅ ∈ f i,
id                            
src    └───────────────┘   
typ    └───────────────┘  
doc    └───────────────┘     
txt    └───────────────┘     
par    └───────────────┘     
pid          └─────────┘     
st   ─────────────────────────────┘└─
1308      from (mem_infi hd hn ∅).1 he,
id             └──────┘ └┘ └┘      └┘
src      └───┘ └──────┘     └──┘
typ      └───┘ └──────┘└┘└┘ └──┘└┘
doc      └───┘              └──┘
txt      └───┘              └──┘
par      └───┘              └──┘
pid      └───┘              └──┘
st   ───────────────────────────────┘└─
1309    exact hb i (empty_in_sets_eq_bot.1 hi)
id           └┘   └──────────────────┘   └┘
src    └────┘    └──────────────────┘└─┘  └┘
typ    └────┘└┘ └──────────────────┘└─┘└┘└┘
doc    └────┘                        └─┘  └┘
txt    └────┘                        └─┘  └┘
par    └────┘                        └─┘  └┘
pid                                 └─┘  
st   ────────────────────────────────────────┘
1310  end
st   └─┘
1311  
1312  /-- If `f : ι → filter α` is derected, `α` is not empty, and `∀ i, f i ≠ ⊥`, then `infi f ≠ ⊥`.
1313  See also `infi_ne_bot_of_directed'` for a version assuming `nonempty ι` instead of `nonempty α`. -/
1314  lemma infi_ne_bot_of_directed {f : ι → filter α}
id                                         └────┘ 
src                                         └────┘
typ                                        └────┘ 
1315    (hn : nonempty α) (hd : directed (≥) f) (hb : ∀i, f i ≠ ⊥) : (infi f) ≠ ⊥ :=
id           └──────┘         └──────┘                       └──┘    
src          └──────┘          └──────┘                           └──┘     
typ          └──────┘         └──────┘                       └──┘    
doc                            └──────┘                              └──┘
1316  if hι : nonempty ι then infi_ne_bot_of_directed' hι hd hb else
id   └┘      └──────┘       └──────────────────────┘ └┘ └┘ └┘
src  └┘      └──────┘        └──────────────────────┘
typ  └┘      └──────┘       └──────────────────────┘ └┘ └┘ └┘
doc                          └──────────────────────┘
1317  assume h : infi f = ⊥,
id   └────┘     └──┘   
src  └────┘     └──┘    
typ  └────┘     └──┘   
doc             └──┘
1318  have univ ⊆ (∅ : set α),
id        └──┘      └─┘ 
src       └──┘      └─┘
typ       └──┘      └─┘ 
1319  begin
st   └─────
1320    rw [←principal_mono, principal_univ, principal_empty, ←h],
id          └────────────┘  └────────────┘  └─────────────┘   
src    └───┘└────────────┘└┘└────────────┘└┘└─────────────┘└─┘ 
typ    └───┘└────────────┘└┘└────────────┘└┘└─────────────┘└─┘
doc    └───┘              └┘              └┘               └─┘ 
txt    └───┘              └┘              └┘               └─┘ 
par    └───┘              └┘              └┘               └─┘ 
pid      └─┘              └┘              └┘               └─┘ 
st   ────────────────────┘└──────────────┘└───────────────┘└──┘└──
1321    exact (le_infi $ assume i, false.elim $ hι ⟨i⟩)
id            └─────┘             └────────┘   └┘
src    └────┘ └─────┘       └──┘└────────┘     └─┘
typ    └────┘ └─────┘       └──┘└────────┘ └┘  └─┘
doc    └────┘               └──┘               └─┘
txt    └────┘               └──┘               └─┘
par    └────┘               └──┘               └─┘
pid                        └──┘               └┘
st   ─────────────────────────────────────────────────┘
1322  end,
st   └─┘
1323  let ⟨x⟩ := hn in this (mem_univ x)
id   └─┘       └┘    └──┘  └──────┘
src                         └──────┘
typ  └─┘       └┘    └──┘  └──────┘
1324  
1325  lemma infi_ne_bot_iff_of_directed' {f : ι → filter α}
id                                              └────┘ 
src                                              └────┘
typ                                             └────┘ 
1326    (hn : nonempty ι) (hd : directed (≥) f) : (infi f) ≠ ⊥ ↔ (∀i, f i ≠ ⊥) :=
id           └──────┘         └──────┘         └──┘             
src          └──────┘          └──────┘          └──┘                 
typ          └──────┘         └──────┘         └──┘             
doc                            └──────┘           └──┘
1327  ⟨assume ne_bot i, ne_bot_of_le_ne_bot ne_bot (infi_le _ i),
id           └────┘   └─────────────────┘ └────┘  └─────┘   
src                    └─────────────────┘         └─────┘
typ          └────┘   └─────────────────┘ └────┘  └─────┘   
1328    infi_ne_bot_of_directed' hn hd⟩
id     └──────────────────────┘ └┘ └┘
src    └──────────────────────┘
typ    └──────────────────────┘ └┘ └┘
doc    └──────────────────────┘
1329  
1330  lemma infi_ne_bot_iff_of_directed {f : ι → filter α}
id                                             └────┘ 
src                                             └────┘
typ                                            └────┘ 
1331    (hn : nonempty α) (hd : directed (≥) f) : (infi f) ≠ ⊥ ↔ (∀i, f i ≠ ⊥) :=
id           └──────┘         └──────┘         └──┘             
src          └──────┘          └──────┘          └──┘                 
typ          └──────┘         └──────┘         └──┘             
doc                            └──────┘           └──┘
1332  ⟨assume ne_bot i, ne_bot_of_le_ne_bot ne_bot (infi_le _ i),
id           └────┘   └─────────────────┘ └────┘  └─────┘   
src                    └─────────────────┘         └─────┘
typ          └────┘   └─────────────────┘ └────┘  └─────┘   
1333    infi_ne_bot_of_directed hn hd⟩
id     └─────────────────────┘ └┘ └┘
src    └─────────────────────┘
typ    └─────────────────────┘ └┘ └┘
doc    └─────────────────────┘
1334  
1335  lemma mem_infi_sets {f : ι → filter α} (i : ι) : ∀{s}, s ∈ f i → s ∈ ⨅i, f i :=
id                               └────┘                           
src                               └────┘                                 
typ                              └────┘                           
doc                                                                        
1336  show (⨅i, f i) ≤ f i, from infi_le _ _
id                      └─────┘
src                          └─────┘
typ                     └─────┘
doc         
1337  
1338  @[elab_as_eliminator]
doc    └────────────────┘
1339  lemma infi_sets_induct {f : ι → filter α} {s : set α} (hs : s ∈ infi f) {p : set α → Prop}
id                                  └────┘        └─┘           └──┘        └─┘ 
src                                  └────┘         └─┘             └──┘         └─┘
typ                                 └────┘        └─┘           └──┘        └─┘ 
doc                                                                  └──┘
1340    (uni : p univ)
id             └──┘
src             └──┘
typ            └──┘
1341    (ins : ∀{i s₁ s₂}, s₁ ∈ f i → p s₂ → p (s₁ ∩ s₂))
id               └┘ └┘   └┘       └┘     └┘  └┘
src                                              
typ              └┘ └┘   └┘       └┘     └┘  └┘
1342    (upw : ∀{s₁ s₂}, s₁ ⊆ s₂ → p s₁ → p s₂) : p s :=
id              └┘ └┘   └┘  └┘    └┘    └┘     
src                        
typ             └┘ └┘   └┘  └┘    └┘    └┘     
1343  begin
st   └─────
1344    rw [mem_infi_finite] at hs,
id         └─────────────┘
src    └──┘└─────────────┘└─────┘
typ    └──┘└─────────────┘└─────┘
doc    └──┘               └─────┘
txt    └──┘               └─────┘
par    └──┘               └─────┘
pid      └┘               └────┘
st   ────────────────────┘└────┘└─
1345    simp only [mem_Union, (finset.inf_eq_infi _ _).symm] at hs,
id                └───────┘   └────────────────┘
src    └─────────┘└───────┘└┘ └────────────────┘└───────────────┘
typ    └─────────┘└───────┘└┘ └────────────────┘└───────────────┘
doc    └─────────┘         └┘                   └───────────────┘
txt    └─────────┘         └┘                   └───────────────┘
par    └─────────┘         └┘                   └───────────────┘
pid        └──┘└┘         └┘                   └─────────┘└───┘
st   ───────────────────────────────────────────────────────────┘└─
1346    rcases hs with ⟨is, his⟩,
id            └┘
src    └─────┘  └─────────────┘
typ    └─────┘└┘└─────────────┘
doc    └─────┘  └─────────────┘
txt    └─────┘  └─────────────┘
par    └─────┘  └─────────────┘
pid            └─────────────┘
st   ─────────────────────────┘└─
1347    revert s,
src    └──────┘
typ    └──────┘
doc    └──────┘
txt    └──────┘
par    └──────┘
pid          └┘
st   ─────────┘└─
1348    refine finset.induction_on is _ _,
id            └─────────────────┘ └┘
src    └─────┘└─────────────────┘  └──┘
typ    └─────┘└─────────────────┘└┘└──┘
doc    └─────┘└─────────────────┘  └──┘
txt    └─────┘                     └──┘
par    └─────┘                     └──┘
pid                               └──┘
st   ──────────────────────────────────┘└─
1349    { assume s hs, rwa [mem_top_sets.1 hs] },
id                         └──────────┘   └┘
src      └─────────┘  └───┘└──────────┘└─┘  └┘
typ      └─────────┘  └───┘└──────────┘└─┘└┘└┘
doc      └─────────┘  └───┘            └─┘  └┘
txt      └─────────┘  └───┘            └─┘  └┘
par      └─────────┘  └───┘            └─┘  └┘
pid      └─────────┘     └┘            └─┘  
st   ───┘└─────────┘└──────────────────────┘└┘
1350    { rintros ⟨i⟩ js his ih s hs,
src      └────────────────────────┘
typ      └────────────────────────┘
doc      └────────────────────────┘
txt      └────────────────────────┘
par      └────────────────────────┘
pid             └─────────────────┘
st   ─────────────────────────────┘└─
1351      rw [finset.inf_insert, mem_inf_sets] at hs,
id           └───────────────┘  └──────────┘
src      └──┘└───────────────┘└┘└──────────┘└─────┘
typ      └──┘└───────────────┘└┘└──────────┘└─────┘
doc      └──┘                 └┘            └─────┘
txt      └──┘                 └┘            └─────┘
par      └──┘                 └┘            └─────┘
pid        └┘                 └┘            └────┘
st   ────────────────────────┘└────────────┘└────┘└─
1352      rcases hs with ⟨s₁, hs₁, s₂, hs₂, hs⟩,
id              └┘
src      └─────┘  └──────────────────────────┘
typ      └─────┘└┘└──────────────────────────┘
doc      └─────┘  └──────────────────────────┘
txt      └─────┘  └──────────────────────────┘
par      └─────┘  └──────────────────────────┘
pid              └──────────────────────────┘
st   ────────────────────────────────────────┘└─
1353      exact upw hs (ins hs₁ (ih hs₂)) }
id             └─┘ └┘  └─┘ └─┘  └┘ └─┘
src      └────┘                  └─┘
typ      └────┘└─┘└┘ └─┘└─┘ └┘└─┘└─┘
doc      └────┘                  └─┘
txt      └────┘                  └─┘
par      └────┘                  └─┘
pid                             └┘
st   ───────────────────────────────────┘└─
1354  end
st   ──┘
1355  
1356  /- tendsto -/
1357  
1358  /-- `tendsto` is the generic "limit of a function" predicate.
1359    `tendsto f l₁ l₂` asserts that for every `l₂` neighborhood `a`,
1360    the `f`-preimage of `a` is an `l₁` neighborhood. -/
1361  def tendsto (f : α → β) (l₁ : filter α) (l₂ : filter β) := l₁.map f ≤ l₂
id                               └────┘         └────┘      └┘└──┘   └┘
src                                └────┘          └────┘         └──┘   
typ                              └────┘         └────┘      └┘└──┘   └┘
doc                                                               └──┘
1362  
1363  lemma tendsto_def {f : α → β} {l₁ : filter α} {l₂ : filter β} :
id                                     └────┘         └────┘ 
src                                      └────┘          └────┘
typ                                    └────┘         └────┘ 
1364    tendsto f l₁ l₂ ↔ ∀ s ∈ l₂, f ⁻¹' s ∈ l₁ := iff.rfl
id     └─────┘  └┘ └┘       └┘   └─┘   └┘    └─────┘
src    └─────┘                      └─┘          └─────┘
typ    └─────┘  └┘ └┘       └┘   └─┘   └┘    └─────┘
doc    └─────┘                       └─┘
1365  
1366  lemma tendsto_iff_comap {f : α → β} {l₁ : filter α} {l₂ : filter β} :
id                                           └────┘         └────┘ 
src                                            └────┘          └────┘
typ                                          └────┘         └────┘ 
1367    tendsto f l₁ l₂ ↔ l₁ ≤ l₂.comap f :=
id     └─────┘  └┘ └┘  └┘  └┘└────┘ 
src    └─────┘                └────┘
typ    └─────┘  └┘ └┘  └┘  └┘└────┘ 
doc    └─────┘                  └────┘
1368  map_le_iff_le_comap
id   └─────────────────┘
src  └─────────────────┘
typ  └─────────────────┘
1369  
1370  lemma tendsto_congr' {f₁ f₂ : α → β} {l₁ : filter α} {l₂ : filter β}
id                                            └────┘         └────┘ 
src                                             └────┘          └────┘
typ                                           └────┘         └────┘ 
1371    (hl : {x | f₁ x = f₂ x} ∈ l₁) :  tendsto f₁ l₁ l₂ ↔ tendsto f₂ l₁ l₂ :=
id              └┘   └┘    └┘     └─────┘ └┘ └┘ └┘  └─────┘ └┘ └┘ └┘
src                                  └─────┘           └─────┘
typ             └┘   └┘    └┘     └─────┘ └┘ └┘ └┘  └─────┘ └┘ └┘ └┘
doc                                     └─────┘            └─────┘
1372  by rw [tendsto, tendsto, map_cong hl]
id          └─────┘  └─────┘  └──────┘ └┘
src     └──┘└─────┘└┘└─────┘└┘└──────┘  └─
typ     └──┘└─────┘└┘└─────┘└┘└──────┘└┘└─
doc     └──┘└─────┘└┘└─────┘└┘          └─
txt     └──┘       └┘       └┘          └─
par     └──┘       └┘       └┘          └─
pid       └┘       └┘       └┘          
st     └──────────┘└───────┘└───────────┘
1373  
src  
typ  
doc  
txt  
par  
pid  
st   
1374  lemma tendsto.congr' {f₁ f₂ : α → β} {l₁ : filter α} {l₂ : filter β}
id                                            └────┘         └────┘ 
src                                             └────┘          └────┘
typ                                           └────┘         └────┘ 
1375    (hl : {x | f₁ x = f₂ x} ∈ l₁) (h : tendsto f₁ l₁ l₂) : tendsto f₂ l₁ l₂ :=
id              └┘   └┘    └┘       └─────┘ └┘ └┘ └┘    └─────┘ └┘ └┘ └┘
src                                    └─────┘             └─────┘
typ             └┘   └┘    └┘       └─────┘ └┘ └┘ └┘    └─────┘ └┘ └┘ └┘
doc                                       └─────┘             └─────┘
1376  (tendsto_congr' hl).1 h
id    └────────────┘ └┘   
src   └────────────┘    
typ   └────────────┘ └┘   
1377  
1378  theorem tendsto_congr {f₁ f₂ : α → β} {l₁ : filter α} {l₂ : filter β}
id                                             └────┘         └────┘ 
src                                              └────┘          └────┘
typ                                            └────┘         └────┘ 
1379    (h : ∀ x, f₁ x = f₂ x) : tendsto f₁ l₁ l₂ ↔ tendsto f₂ l₁ l₂ :=
id              └┘   └┘     └─────┘ └┘ └┘ └┘  └─────┘ └┘ └┘ └┘
src                            └─────┘           └─────┘
typ             └┘   └┘     └─────┘ └┘ └┘ └┘  └─────┘ └┘ └┘ └┘
doc                             └─────┘            └─────┘
1380  tendsto_congr' (univ_mem_sets' h)
id   └────────────┘  └────────────┘ 
src  └────────────┘  └────────────┘
typ  └────────────┘  └────────────┘ 
1381  
1382  theorem tendsto.congr {f₁ f₂ : α → β} {l₁ : filter α} {l₂ : filter β}
id                                             └────┘         └────┘ 
src                                              └────┘          └────┘
typ                                            └────┘         └────┘ 
1383    (h : ∀ x, f₁ x = f₂ x) : tendsto f₁ l₁ l₂ → tendsto f₂ l₁ l₂ :=
id              └┘   └┘     └─────┘ └┘ └┘ └┘   └─────┘ └┘ └┘ └┘
src                            └─────┘            └─────┘
typ             └┘   └┘     └─────┘ └┘ └┘ └┘   └─────┘ └┘ └┘ └┘
doc                             └─────┘            └─────┘
1384  (tendsto_congr h).1
id    └───────────┘  
src   └───────────┘   
typ   └───────────┘  
1385  
1386  lemma tendsto_id' {x y : filter α} : x ≤ y → tendsto id x y :=
id                            └────┘          └─────┘ └┘  
src                           └────┘             └─────┘ └┘
typ                           └────┘          └─────┘ └┘  
doc                                               └─────┘
1387  by simp only [tendsto, map_id, forall_true_iff] {contextual := tt}
id                 └─────┘  └────┘  └─────────────┘                 └┘
src     └─────────┘└─────┘└┘└────┘└┘└─────────────┘└┘ └────────────┘└┘└─
typ     └─────────┘└─────┘└┘└────┘└┘└─────────────┘└┘ └────────────┘└┘└─
doc     └─────────┘└─────┘└┘      └┘               └┘ └────────────┘  └─
txt     └─────────┘       └┘      └┘               └┘ └────────────┘  └─
par     └─────────┘       └┘      └┘               └┘ └────────────┘  └─
pid         └──┘└┘       └┘      └┘                └────────────┘  
st     └────────────────────────────────────────────────────────────────
1388  
src  
typ  
doc  
txt  
par  
pid  
st   
1389  lemma tendsto_id {x : filter α} : tendsto id x x := tendsto_id' $ le_refl x
id                         └────┘     └─────┘ └┘      └─────────┘   └─────┘ 
src                        └────┘      └─────┘ └┘        └─────────┘   └─────┘
typ                        └────┘     └─────┘ └┘      └─────────┘   └─────┘ 
doc                                    └─────┘
1390  
1391  lemma tendsto.comp {f : α → β} {g : β → γ} {x : filter α} {y : filter β} {z : filter γ}
id                                               └────┘        └────┘        └────┘ 
src                                                  └────┘         └────┘         └────┘
typ                                              └────┘        └────┘        └────┘ 
1392    (hg : tendsto g y z) (hf : tendsto f x y) : tendsto (g ∘ f) x z :=
id           └─────┘           └─────┘       └─────┘       
src          └─────┘              └─────┘          └─────┘    
typ          └─────┘           └─────┘       └─────┘       
doc          └─────┘              └─────┘          └─────┘
1393  calc map (g ∘ f) x = map g (map f x) : by rw [map_map]
id        └─┘         └─┘   └─┘             └─────┘
src       └─┘            └─┘    └─┘           └──┘└─────┘└─
typ       └─┘         └─┘   └─┘         └──┘└─────┘└─
doc       └─┘             └─┘    └─┘           └──┘       └─
txt                                            └──┘       └─
par                                            └──┘       └─
pid                                              └┘       
st                                            └──────────┘
1394    ... ≤ map g y : map_mono hf
id           └─┘     └──────┘ └┘
src  ─┘      └─┘       └──────┘
typ  ─┘      └─┘     └──────┘ └┘
doc  ─┘      └─┘
txt  ─┘
par  ─┘
pid  ─┘
st   ─┘
1395    ... ≤ z : hg
id              └┘
typ             └┘
1396  
1397  lemma tendsto_le_left {f : α → β} {x y : filter α} {z : filter β}
id                                          └────┘        └────┘ 
src                                           └────┘         └────┘
typ                                         └────┘        └────┘ 
1398    (h : y ≤ x) : tendsto f x z → tendsto f y z :=
id                └─────┘      └─────┘   
src                 └─────┘         └─────┘
typ               └─────┘      └─────┘   
doc                  └─────┘         └─────┘
1399  le_trans (map_mono h)
id   └──────┘  └──────┘ 
src  └──────┘  └──────┘
typ  └──────┘  └──────┘ 
1400  
1401  lemma tendsto_le_right {f : α → β} {x : filter α} {y z : filter β}
id                                         └────┘          └────┘ 
src                                          └────┘           └────┘
typ                                        └────┘          └────┘ 
1402    (h₁ : y ≤ z) (h₂ : tendsto f x y) : tendsto f x z :=
id                     └─────┘       └─────┘   
src                      └─────┘          └─────┘
typ                    └─────┘       └─────┘   
doc                       └─────┘          └─────┘
1403  le_trans h₂ h₁
id   └──────┘ └┘ └┘
src  └──────┘
typ  └──────┘ └┘ └┘
1404  
1405  lemma tendsto.ne_bot {f : α → β} {x : filter α} {y : filter β} (h : tendsto f x y) (hx : x ≠ ⊥) :
id                                       └────┘        └────┘        └─────┘             
src                                        └────┘         └────┘         └─────┘                 
typ                                      └────┘        └────┘        └─────┘             
doc                                                                      └─────┘
1406    y ≠ ⊥ :=
id       
src       
typ      
1407  ne_bot_of_le_ne_bot (map_ne_bot hx) h
id   └─────────────────┘  └────────┘ └┘  
src  └─────────────────┘  └────────┘
typ  └─────────────────┘  └────────┘ └┘  
1408  
1409  lemma tendsto_map {f : α → β} {x : filter α} : tendsto f x (map f x) := le_refl (map f x)
id                                    └────┘     └─────┘    └─┘       └─────┘  └─┘  
src                                     └────┘      └─────┘      └─┘         └─────┘  └─┘
typ                                   └────┘     └─────┘    └─┘       └─────┘  └─┘  
doc                                                 └─────┘      └─┘                  └─┘
1410  
1411  lemma tendsto_map' {f : β → γ} {g : α → β} {x : filter α} {y : filter γ}
id                                               └────┘        └────┘ 
src                                                  └────┘         └────┘
typ                                              └────┘        └────┘ 
1412    (h : tendsto (f ∘ g) x y) : tendsto f (map g x) y :=
id          └─────┘           └─────┘   └─┘    
src         └─────┘               └─────┘    └─┘
typ         └─────┘           └─────┘   └─┘    
doc         └─────┘                └─────┘    └─┘
1413  by rwa [tendsto, map_map]
id           └─────┘  └─────┘
src     └───┘└─────┘└┘└─────┘└─
typ     └───┘└─────┘└┘└─────┘└─
doc     └───┘└─────┘└┘       └─
txt     └───┘       └┘       └─
par     └───┘       └┘       └─
pid        └┘       └┘       
st     └───────────┘└───────┘
1414  
src  
typ  
doc  
txt  
par  
pid  
st   
1415  lemma tendsto_map'_iff {f : β → γ} {g : α → β} {x : filter α} {y : filter γ} :
id                                                   └────┘        └────┘ 
src                                                      └────┘         └────┘
typ                                                  └────┘        └────┘ 
1416    tendsto f (map g x) y ↔ tendsto (f ∘ g) x y :=
id     └─────┘   └─┘      └─────┘       
src    └─────┘    └─┘         └─────┘    
typ    └─────┘   └─┘      └─────┘       
doc    └─────┘    └─┘          └─────┘
1417  by rw [tendsto, map_map]; refl
id          └─────┘  └─────┘
src     └──┘└─────┘└┘└─────┘  └────
typ     └──┘└─────┘└┘└─────┘  └────
doc     └──┘└─────┘└┘         └────
txt     └──┘       └┘         └────
par     └──┘       └┘         └────
pid       └┘       └┘             
st     └──────────┘└───────┘└──────
1418  
src  
typ  
doc  
txt  
par  
pid  
st   
1419  lemma tendsto_comap {f : α → β} {x : filter β} : tendsto f (comap f x) x :=
id                                      └────┘     └─────┘   └───┘    
src                                       └────┘      └─────┘    └───┘
typ                                     └────┘     └─────┘   └───┘    
doc                                                   └─────┘    └───┘
1420  map_comap_le
id   └──────────┘
src  └──────────┘
typ  └──────────┘
1421  
1422  lemma tendsto_comap_iff {f : α → β} {g : β → γ} {a : filter α} {c : filter γ} :
id                                                    └────┘        └────┘ 
src                                                       └────┘         └────┘
typ                                                   └────┘        └────┘ 
1423    tendsto f a (c.comap g) ↔ tendsto (g ∘ f) a c :=
id     └─────┘    └────┘    └─────┘       
src    └─────┘       └────┘     └─────┘    
typ    └─────┘    └────┘    └─────┘       
doc    └─────┘       └────┘      └─────┘
1424  ⟨assume h, tendsto_comap.comp h, assume h, map_le_iff_le_comap.mp $ by rwa [map_map]⟩
id             └───────────┘└───┘            └─────────────────┘└─┘           └─────┘
src             └───────────┘└───┘              └─────────────────┘└─┘      └───┘└─────┘
typ            └───────────┘└───┘            └─────────────────┘└─┘      └───┘└─────┘
doc                                                                         └───┘       
txt                                                                         └───┘       
par                                                                         └───┘       
pid                                                                            └┘       
st                                                                         └───────────┘
1425  
1426  lemma tendsto_comap'_iff {m : α → β} {f : filter α} {g : filter β} {i : γ → α}
id                                           └────┘        └────┘           
src                                            └────┘         └────┘
typ                                          └────┘        └────┘           
1427    (h : range i ∈ f) : tendsto (m ∘ i) (comap i f) g ↔ tendsto m f g :=
id          └───┘       └─────┘       └───┘      └─────┘   
src         └───┘         └─────┘         └───┘         └─────┘
typ         └───┘       └─────┘       └───┘      └─────┘   
doc         └───┘          └─────┘          └───┘          └─────┘
1428  by rw [tendsto, ← map_compose]; simp only [(∘), map_comap h, tendsto]
id          └─────┘    └─────────┘                  └───────┘   └─────┘
src     └──┘└─────┘└──┘└─────────┘  └─────────┘└──┘└───────┘ └┘└─────┘└─
typ     └──┘└─────┘└──┘└─────────┘  └─────────┘└──┘└───────┘└┘└─────┘└─
doc     └──┘└─────┘└──┘             └─────────┘ └──┘          └┘└─────┘└─
txt     └──┘       └──┘             └─────────┘ └──┘          └┘       └─
par     └──┘       └──┘             └─────────┘ └──┘          └┘       └─
pid       └┘       └──┘                 └──┘└┘ └──┘          └┘       
st     └──────────┘└─────────────┘└───────────────────────────────────────
1429  
src  
typ  
doc  
txt  
par  
pid  
st   
1430  lemma comap_eq_of_inverse {f : filter α} {g : filter β} {φ : α → β} (ψ : β → α)
id                                  └────┘        └────┘                     
src                                 └────┘         └────┘
typ                                 └────┘        └────┘                     
1431    (eq : ψ ∘ φ = id) (hφ : tendsto φ f g) (hψ : tendsto ψ g f) : comap φ g = f :=
id               └┘        └─────┘           └─────┘       └───┘    
src                └┘        └─────┘              └─────┘          └───┘     
typ              └┘        └─────┘           └─────┘       └───┘    
doc                            └─────┘              └─────┘          └───┘
1432  begin
st   └─────
1433    refine le_antisymm (le_trans (comap_mono $ map_le_iff_le_comap.1 hψ) _) (map_le_iff_le_comap.1 hφ),
id            └─────────┘  └──────┘  └────────┘                         └┘      └─────────────────┘   └┘
src    └─────┘└─────────┘ └──────┘ └────────┘                    └─┘  └───┘ └─────────────────┘└─┘  
typ    └─────┘└─────────┘ └──────┘ └────────┘                    └─┘└┘└───┘ └─────────────────┘└─┘└┘
doc    └─────┘                                                   └─┘  └───┘                    └─┘  
txt    └─────┘                                                   └─┘  └───┘                    └─┘  
par    └─────┘                                                   └─┘  └───┘                    └─┘  
pid                                                             └─┘  └───┘                    └─┘  
st   ───────────────────────────────────────────────────────────────────────────────────────────────────┘└─
1434    rw [comap_comap_comp, eq, comap_id],
id         └──────────────┘  └┘  └──────┘
src    └──┘└──────────────┘└┘└┘└┘└──────┘
typ    └──┘└──────────────┘└┘└┘└┘└──────┘
doc    └──┘                └┘  └┘        
txt    └──┘                └┘  └┘        
par    └──┘                └┘  └┘        
pid      └┘                └┘  └┘        
st   ─────────────────────┘└──┘└────────┘└──
1435    exact le_refl _
id           └─────┘
src    └────┘└─────┘└─┘
typ    └────┘└─────┘└─┘
doc    └────┘       └─┘
txt    └────┘       └─┘
par    └────┘       └─┘
pid                └┘
st   ─────────────────┘
1436  end
st   └─┘
1437  
1438  lemma map_eq_of_inverse {f : filter α} {g : filter β} {φ : α → β} (ψ : β → α)
id                                └────┘        └────┘                     
src                               └────┘         └────┘
typ                               └────┘        └────┘                     
1439    (eq : φ ∘ ψ = id) (hφ : tendsto φ f g) (hψ : tendsto ψ g f) : map φ f = g :=
id               └┘        └─────┘           └─────┘       └─┘    
src                └┘        └─────┘              └─────┘          └─┘     
typ              └┘        └─────┘           └─────┘       └─┘    
doc                            └─────┘              └─────┘          └─┘
1440  begin
st   └─────
1441    refine le_antisymm hφ (le_trans _ (map_mono hψ)),
id            └─────────┘ └┘  └──────┘    └──────┘ └┘
src    └─────┘└─────────┘   └──────┘└─┘ └──────┘  └┘
typ    └─────┘└─────────┘└┘ └──────┘└─┘ └──────┘└┘└┘
doc    └─────┘                      └─┘           └┘
txt    └─────┘                      └─┘           └┘
par    └─────┘                      └─┘           └┘
pid                                └─┘           └┘
st   ─────────────────────────────────────────────────┘└─
1442    rw [map_map, eq, map_id],
id         └─────┘  └┘  └────┘
src    └──┘└─────┘└┘└┘└┘└────┘
typ    └──┘└─────┘└┘└┘└┘└────┘
doc    └──┘       └┘  └┘      
txt    └──┘       └┘  └┘      
par    └──┘       └┘  └┘      
pid      └┘       └┘  └┘      
st   ────────────┘└──┘└──────┘└──
1443    exact le_refl _
id           └─────┘
src    └────┘└─────┘└─┘
typ    └────┘└─────┘└─┘
doc    └────┘       └─┘
txt    └────┘       └─┘
par    └────┘       └─┘
pid                └┘
st   ─────────────────┘
1444  end
st   └─┘
1445  
1446  lemma tendsto_inf {f : α → β} {x : filter α} {y₁ y₂ : filter β} :
id                                    └────┘            └────┘ 
src                                     └────┘             └────┘
typ                                   └────┘            └────┘ 
1447    tendsto f x (y₁ ⊓ y₂) ↔ tendsto f x y₁ ∧ tendsto f x y₂ :=
id     └─────┘    └┘  └┘   └─────┘   └┘  └─────┘   └┘
src    └─────┘               └─────┘         └─────┘
typ    └─────┘    └┘  └┘   └─────┘   └┘  └─────┘   └┘
doc    └─────┘                 └─────┘          └─────┘
1448  by simp only [tendsto, lattice.le_inf_iff, iff_self]
id                 └─────┘  └────────────────┘  └──────┘
src     └─────────┘└─────┘└┘└────────────────┘└┘└──────┘└─
typ     └─────────┘└─────┘└┘└────────────────┘└┘└──────┘└─
doc     └─────────┘└─────┘└┘                  └┘        └─
txt     └─────────┘       └┘                  └┘        └─
par     └─────────┘       └┘                  └┘        └─
pid         └──┘└┘       └┘                  └┘        
st     └──────────────────────────────────────────────────
1449  
src  
typ  
doc  
txt  
par  
pid  
st   
1450  lemma tendsto_inf_left {f : α → β} {x₁ x₂ : filter α} {y : filter β}
id                                             └────┘        └────┘ 
src                                              └────┘         └────┘
typ                                            └────┘        └────┘ 
1451    (h : tendsto f x₁ y) : tendsto f (x₁ ⊓ x₂) y  :=
id          └─────┘  └┘     └─────┘   └┘  └┘  
src         └─────┘           └─────┘       
typ         └─────┘  └┘     └─────┘   └┘  └┘  
doc         └─────┘           └─────┘
1452  le_trans (map_mono inf_le_left) h
id   └──────┘  └──────┘ └─────────┘  
src  └──────┘  └──────┘ └─────────┘
typ  └──────┘  └──────┘ └─────────┘  
1453  
1454  lemma tendsto_inf_right {f : α → β} {x₁ x₂ : filter α} {y : filter β}
id                                              └────┘        └────┘ 
src                                               └────┘         └────┘
typ                                             └────┘        └────┘ 
1455    (h : tendsto f x₂ y) : tendsto f (x₁ ⊓ x₂) y  :=
id          └─────┘  └┘     └─────┘   └┘  └┘  
src         └─────┘           └─────┘       
typ         └─────┘  └┘     └─────┘   └┘  └┘  
doc         └─────┘           └─────┘
1456  le_trans (map_mono inf_le_right) h
id   └──────┘  └──────┘ └──────────┘  
src  └──────┘  └──────┘ └──────────┘
typ  └──────┘  └──────┘ └──────────┘  
1457  
1458  lemma tendsto.inf {f : α → β} {x₁ x₂ : filter α} {y₁ y₂ : filter β}
id                                        └────┘            └────┘ 
src                                         └────┘             └────┘
typ                                       └────┘            └────┘ 
1459    (h₁ : tendsto f x₁ y₁) (h₂ : tendsto f x₂ y₂) : tendsto f (x₁ ⊓ x₂) (y₁ ⊓ y₂) :=
id           └─────┘  └┘ └┘        └─────┘  └┘ └┘    └─────┘   └┘  └┘   └┘  └┘
src          └─────┘                └─────┘            └─────┘                
typ          └─────┘  └┘ └┘        └─────┘  └┘ └┘    └─────┘   └┘  └┘   └┘  └┘
doc          └─────┘                └─────┘            └─────┘
1460  tendsto_inf.2 ⟨tendsto_inf_left h₁, tendsto_inf_right h₂⟩
id   └─────────┘   └──────────────┘ └┘  └───────────────┘ └┘
src  └─────────┘   └──────────────┘     └───────────────┘
typ  └─────────┘   └──────────────┘ └┘  └───────────────┘ └┘
1461  
1462  lemma tendsto_infi {f : α → β} {x : filter α} {y : ι → filter β} :
id                                     └────┘           └────┘ 
src                                      └────┘             └────┘
typ                                    └────┘           └────┘ 
1463    tendsto f x (⨅i, y i) ↔ ∀i, tendsto f x (y i) :=
id     └─────┘            └─────┘     
src    └─────┘                  └─────┘
typ    └─────┘            └─────┘     
doc    └─────┘                   └─────┘
1464  by simp only [tendsto, iff_self, lattice.le_infi_iff]
id                 └─────┘  └──────┘  └─────────────────┘
src     └─────────┘└─────┘└┘└──────┘└┘└─────────────────┘└─
typ     └─────────┘└─────┘└┘└──────┘└┘└─────────────────┘└─
doc     └─────────┘└─────┘└┘        └┘                   └─
txt     └─────────┘       └┘        └┘                   └─
par     └─────────┘       └┘        └┘                   └─
pid         └──┘└┘       └┘        └┘                   
st     └───────────────────────────────────────────────────
1465  
src  
typ  
doc  
txt  
par  
pid  
st   
1466  lemma tendsto_infi' {f : α → β} {x : ι → filter α} {y : filter β} (i : ι) :
id                                         └────┘        └────┘        
src                                           └────┘         └────┘
typ                                        └────┘        └────┘        
1467    tendsto f (x i) y → tendsto f (⨅i, x i) y :=
id     └─────┘         └─────┘       
src    └─────┘             └─────┘     
typ    └─────┘         └─────┘       
doc    └─────┘             └─────┘     
1468  tendsto_le_left (infi_le _ _)
id   └─────────────┘  └─────┘
src  └─────────────┘  └─────┘
typ  └─────────────┘  └─────┘
1469  
1470  lemma tendsto_principal {f : α → β} {l : filter α} {s : set β} :
id                                          └────┘        └─┘ 
src                                           └────┘         └─┘
typ                                         └────┘        └─┘ 
1471    tendsto f l (principal s) ↔ ∀ᶠ a in l, f a ∈ s :=
id     └─────┘    └───────┘    └┘  └┘     
src    └─────┘      └───────┘     └┘   └┘       
typ    └─────┘    └───────┘    └┘  └┘     
doc    └─────┘      └───────┘      └┘   └┘  
1472  by simp only [tendsto, le_principal_iff, mem_map, iff_self, filter.eventually]
id                 └─────┘  └──────────────┘  └─────┘  └──────┘  └───────────────┘
src     └─────────┘└─────┘└┘└──────────────┘└┘└─────┘└┘└──────┘└┘└───────────────┘└─
typ     └─────────┘└─────┘└┘└──────────────┘└┘└─────┘└┘└──────┘└┘└───────────────┘└─
doc     └─────────┘└─────┘└┘                └┘       └┘        └┘└───────────────┘└─
txt     └─────────┘       └┘                └┘       └┘        └┘                 └─
par     └─────────┘       └┘                └┘       └┘        └┘                 └─
pid         └──┘└┘       └┘                └┘       └┘        └┘                 
st     └────────────────────────────────────────────────────────────────────────────
1473  
src  
typ  
doc  
txt  
par  
pid  
st   
1474  lemma tendsto_principal_principal {f : α → β} {s : set α} {t : set β} :
id                                                    └─┘        └─┘ 
src                                                     └─┘         └─┘
typ                                                   └─┘        └─┘ 
1475    tendsto f (principal s) (principal t) ↔ ∀a∈s, f a ∈ t :=
id     └─────┘   └───────┘    └───────┘           
src    └─────┘    └───────┘     └───────┘               
typ    └─────┘   └───────┘    └───────┘           
doc    └─────┘    └───────┘     └───────┘
1476  by simp only [tendsto, image_subset_iff, le_principal_iff, map_principal, mem_principal_sets]; refl
id                 └─────┘  └──────────────┘  └──────────────┘  └───────────┘  └────────────────┘
src     └─────────┘└─────┘└┘└──────────────┘└┘└──────────────┘└┘└───────────┘└┘└────────────────┘  └────
typ     └─────────┘└─────┘└┘└──────────────┘└┘└──────────────┘└┘└───────────┘└┘└────────────────┘  └────
doc     └─────────┘└─────┘└┘└──────────────┘└┘                └┘             └┘                    └────
txt     └─────────┘       └┘                └┘                └┘             └┘                    └────
par     └─────────┘       └┘                └┘                └┘             └┘                    └────
pid         └──┘└┘       └┘                └┘                └┘             └┘                        
st     └─────────────────────────────────────────────────────────────────────────────────────────────────
1477  
src  
typ  
doc  
txt  
par  
pid  
st   
1478  lemma tendsto_pure {f : α → β} {a : filter α} {b : β} :
id                                     └────┘        
src                                      └────┘
typ                                    └────┘        
1479    tendsto f a (pure b) ↔ {x | f x = b} ∈ a :=
id     └─────┘    └──┘             
src    └─────┘      └──┘                 
typ    └─────┘    └──┘             
doc    └─────┘
1480  by simp only [tendsto, le_pure_iff, mem_map, mem_singleton_iff]
id                 └─────┘  └─────────┘  └─────┘  └───────────────┘
src     └─────────┘└─────┘└┘└─────────┘└┘└─────┘└┘└───────────────┘└─
typ     └─────────┘└─────┘└┘└─────────┘└┘└─────┘└┘└───────────────┘└─
doc     └─────────┘└─────┘└┘           └┘       └┘                 └─
txt     └─────────┘       └┘           └┘       └┘                 └─
par     └─────────┘       └┘           └┘       └┘                 └─
pid         └──┘└┘       └┘           └┘       └┘                 
st     └─────────────────────────────────────────────────────────────
1481  
src  
typ  
doc  
txt  
par  
pid  
st   
1482  lemma tendsto_pure_pure (f : α → β) (a : α) :
id                                          
typ                                         
1483    tendsto f (pure a) (pure (f a)) :=
id     └─────┘   └──┘    └──┘   
src    └─────┘    └──┘     └──┘
typ    └─────┘   └──┘    └──┘   
doc    └─────┘
1484  tendsto_pure.2 rfl
id   └──────────┘  └─┘
src  └──────────┘  └─┘
typ  └──────────┘  └─┘
1485  
1486  lemma tendsto_const_pure {a : filter α} {b : β} : tendsto (λx, b) a (pure b) :=
id                                 └────┘            └─────┘         └──┘ 
src                                └────┘              └─────┘            └──┘
typ                                └────┘            └─────┘         └──┘ 
doc                                                    └─────┘
1487  tendsto_pure.2 $ univ_mem_sets' $ λ _, rfl
id   └──────────┘    └────────────┘       └─┘
src  └──────────┘    └────────────┘        └─┘
typ  └──────────┘    └────────────┘       └─┘
1488  
1489  lemma tendsto_if {l₁ : filter α} {l₂ : filter β}
id                          └────┘         └────┘ 
src                         └────┘          └────┘
typ                         └────┘         └────┘ 
1490      {f g : α → β} {p : α → Prop} [decidable_pred p]
id                                  └────────────┘ 
src                                    └────────────┘
typ                                 └────────────┘ 
1491      (h₀ : tendsto f (l₁ ⊓ principal p) l₂)
id             └─────┘   └┘  └───────┘   └┘
src            └─────┘        └───────┘
typ            └─────┘   └┘  └───────┘   └┘
doc            └─────┘         └───────┘
1492      (h₁ : tendsto g (l₁ ⊓ principal { x | ¬ p x }) l₂) :
id             └─────┘   └┘  └───────┘           └┘
src            └─────┘        └───────┘      
typ            └─────┘   └┘  └───────┘           └┘
doc            └─────┘         └───────┘
1493    tendsto (λ x, if p x then f x else g x) l₁ l₂ :=
id     └─────┘                          └┘ └┘
src    └─────┘
typ    └─────┘                          └┘ └┘
doc    └─────┘
1494  begin
st   └─────
1495    revert h₀ h₁, simp only [tendsto_def, mem_inf_principal],
id                              └─────────┘  └───────────────┘
src    └──────────┘  └─────────┘└─────────┘└┘└───────────────┘
typ    └──────────┘  └─────────┘└─────────┘└┘└───────────────┘
doc    └──────────┘  └─────────┘           └┘                 
txt    └──────────┘  └─────────┘           └┘                 
par    └──────────┘  └─────────┘           └┘                 
pid          └────┘      └──┘└┘           └┘                 
st   ─────────────┘└──────────────────────────────────────────┘└─
1496    intros h₀ h₁ s hs,
src    └───────────────┘
typ    └───────────────┘
doc    └───────────────┘
txt    └───────────────┘
par    └───────────────┘
pid          └─────────┘
st   ──────────────────┘└─
1497    apply mem_sets_of_superset (inter_mem_sets (h₀ s hs) (h₁ s hs)),
id           └──────────────────┘  └────────────┘  └┘        └┘  └┘
src    └────┘└──────────────────┘ └────────────┘      └┘      └┘
typ    └────┘└──────────────────┘ └────────────┘ └┘   └┘ └┘└┘└┘
doc    └────┘                                         └┘      └┘
txt    └────┘                                         └┘      └┘
par    └────┘                                         └┘      └┘
pid                                                  └┘      └┘
st   ────────────────────────────────────────────────────────────────┘└─
1498    rintros x ⟨hp₀, hp₁⟩, simp only [mem_preimage],
id                                      └──────────┘
src    └──────────────────┘  └─────────┘└──────────┘
typ    └──────────────────┘  └─────────┘└──────────┘
doc    └──────────────────┘  └─────────┘            
txt    └──────────────────┘  └─────────┘            
par    └──────────────────┘  └─────────┘            
pid           └───────────┘      └──┘└┘            
st   ─────────────────────┘└────────────────────────┘└─
1499    by_cases h : p x,
id                   
src    └───────┘ └─┘ 
typ    └───────┘ └─┘
doc    └───────┘ └─┘ 
txt    └───────┘ └─┘ 
par    └───────┘ └─┘ 
pid             └─┘ 
st   ─────────────────┘└─
1500    { rw if_pos h, exact hp₀ h },
id          └────┘         └─┘ 
src      └─┘└────┘   └────┘    
typ      └─┘└────┘  └────┘└─┘
doc      └─┘         └────┘    
txt      └─┘         └────┘    
par      └─┘         └────┘    
pid                          
st   ───┘└─────────┘└────────────┘└┘
1501    rw if_neg h, exact hp₁ h
id        └────┘         └─┘ 
src    └─┘└────┘   └────┘    
typ    └─┘└────┘  └────┘└─┘
doc    └─┘         └────┘    
txt    └─┘         └────┘    
par    └─┘         └────┘    
pid                        
st   ────────────┘└────────────┘
1502  end
st   └─┘
1503  
1504  
1505  section prod
1506  variables {s : set α} {t : set β} {f : filter α} {g : filter β}
id                  └─┘         └─┘         └────┘         └────┘
src                 └─┘         └─┘         └────┘         └────┘
typ                 └─┘         └─┘         └────┘         └────┘
1507  /- The product filter cannot be defined using the monad structure on filters. For example:
1508  
1509    F := do {x ← seq, y ← top, return (x, y)}
1510    hence:
1511      s ∈ F  ↔  ∃n, [n..∞] × univ ⊆ s
1512  
1513    G := do {y ← top, x ← seq, return (x, y)}
1514    hence:
1515      s ∈ G  ↔  ∀i:ℕ, ∃n, [n..∞] × {i} ⊆ s
1516  
1517    Now ⋃i, [i..∞] × {i}  is in G but not in F.
1518  
1519    As product filter we want to have F as result.
1520  -/
1521  
1522  /-- Product of filters. This is the filter generated by cartesian products
1523    of elements of the component filters. -/
1524  protected def prod (f : filter α) (g : filter β) : filter (α × β) :=
id                           └────┘        └────┘     └────┘    
src                          └────┘         └────┘      └────┘    
typ                          └────┘        └────┘     └────┘    
1525  f.comap prod.fst ⊓ g.comap prod.snd
id   └────┘ └──────┘  └────┘ └──────┘
src   └────┘ └──────┘   └────┘ └──────┘
typ  └────┘ └──────┘  └────┘ └──────┘
doc   └────┘             └────┘
1526  
1527  lemma prod_mem_prod {s : set α} {t : set β} {f : filter α} {g : filter β}
id                            └─┘        └─┘        └────┘        └────┘ 
src                           └─┘         └─┘         └────┘         └────┘
typ                           └─┘        └─┘        └────┘        └────┘ 
1528    (hs : s ∈ f) (ht : t ∈ g) : set.prod s t ∈ filter.prod f g :=
id                           └──────┘    └─────────┘  
src                              └──────┘      └─────────┘
typ                          └──────┘    └─────────┘  
doc                                └──────┘       └─────────┘
1529  inter_mem_inf_sets (preimage_mem_comap hs) (preimage_mem_comap ht)
id   └────────────────┘  └────────────────┘ └┘   └────────────────┘ └┘
src  └────────────────┘  └────────────────┘      └────────────────┘
typ  └────────────────┘  └────────────────┘ └┘   └────────────────┘ └┘
1530  
1531  lemma mem_prod_iff {s : set (α×β)} {f : filter α} {g : filter β} :
id                           └─┘          └────┘        └────┘ 
src                          └─┘            └────┘         └────┘
typ                          └─┘          └────┘        └────┘ 
1532    s ∈ filter.prod f g ↔ (∃ t₁ ∈ f, ∃ t₂ ∈ g, set.prod t₁ t₂ ⊆ s) :=
id       └─────────┘      └┘     └┘    └──────┘ └┘ └┘  
src       └─────────┘                       └──────┘       
typ      └─────────┘      └┘     └┘    └──────┘ └┘ └┘  
doc        └─────────┘                            └──────┘
1533  begin
st   └─────
1534    simp only [filter.prod],
id                └─────────┘
src    └─────────┘└─────────┘
typ    └─────────┘└─────────┘
doc    └─────────┘└─────────┘
txt    └─────────┘           
par    └─────────┘           
pid        └──┘└┘           
st   ────────────────────────┘└─
1535    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
1536    exact assume ⟨t₁, ⟨s₁, hs₁, hts₁⟩, t₂, ⟨s₂, hs₂, hts₂⟩, h⟩,
id                        └┘  └─┘  └──┘        └┘  └─┘  └──┘   
src    └────┘      └┘  └┘   └┘   └┘    └─┘  └┘   └┘   └┘    └─┘ └──
typ    └────┘      └┘  └┘ └┘└┘└─┘└┘└──┘└─┘  └┘ └┘└┘└─┘└┘└──┘└─┘└──
doc    └────┘      └┘  └┘   └┘   └┘    └─┘  └┘   └┘   └┘    └─┘ └──
txt    └────┘      └┘  └┘   └┘   └┘    └─┘  └┘   └┘   └┘    └─┘ └──
par    └────┘      └┘  └┘   └┘   └┘    └─┘  └┘   └┘   └┘    └─┘ └──
pid               └┘  └┘   └┘   └┘    └─┘  └┘   └┘   └┘    └─┘ └──
st   ──────────────────────────────────────────────────────────────
1537      ⟨s₁, hs₁, s₂, hs₂, subset.trans (inter_subset_inter hts₁ hts₂) h⟩,
id                          └──────────┘  └────────────────┘
src  ───┘   └┘   └┘  └┘   └┘└──────────┘ └────────────────┘        └┘ 
typ  ───┘   └┘   └┘  └┘   └┘└──────────┘ └────────────────┘        └┘ 
doc  ───┘   └┘   └┘  └┘   └┘                                       └┘ 
txt  ───┘   └┘   └┘  └┘   └┘                                       └┘ 
par  ───┘   └┘   └┘  └┘   └┘                                       └┘ 
pid  ───┘   └┘   └┘  └┘   └┘                                       └┘ 
st   ────────────────────────────────────────────────────────────────────┘└─
1538    exact assume ⟨t₁, ht₁, t₂, ht₂, h⟩,
id                   └┘  └─┘  └┘  └─┘  
src    └────┘      └┘  └┘   └┘  └┘   └┘ └──
typ    └────┘      └┘└┘└┘└─┘└┘└┘└┘└─┘└┘└──
doc    └────┘      └┘  └┘   └┘  └┘   └┘ └──
txt    └────┘      └┘  └┘   └┘  └┘   └┘ └──
par    └────┘      └┘  └┘   └┘  └┘   └┘ └──
pid               └┘  └┘   └┘  └┘   └┘ └──
st   ──────────────────────────────────────
1539      ⟨prod.fst ⁻¹' t₁, ⟨t₁, ht₁, subset.refl _⟩, prod.snd ⁻¹' t₂, ⟨t₂, ht₂, subset.refl _⟩, h⟩
id        └──────┘ └─┘                               └──────┘                   └─────────┘
src  ───┘ └──────┘└─┘  └┘   └┘   └┘           └───┘└──────┘     └┘   └┘   └┘└─────────┘└───┘ └┘
typ  ───┘ └──────┘└─┘  └┘   └┘   └┘           └───┘└──────┘     └┘   └┘   └┘└─────────┘└───┘ └┘
doc  ───┘         └─┘  └┘   └┘   └┘           └───┘             └┘   └┘   └┘           └───┘ └┘
txt  ───┘              └┘   └┘   └┘           └───┘             └┘   └┘   └┘           └───┘ └┘
par  ───┘              └┘   └┘   └┘           └───┘             └┘   └┘   └┘           └───┘ └┘
pid  ───┘              └┘   └┘   └┘           └───┘             └┘   └┘   └┘           └───┘ 
st   ─────────────────────────────────────────────────────────────────────────────────────────────┘
1540  end
st   └─┘
1541  
1542  lemma tendsto_fst {f : filter α} {g : filter β} : tendsto prod.fst (filter.prod f g) f :=
id                          └────┘        └────┘     └─────┘ └──────┘  └─────────┘    
src                         └────┘         └────┘      └─────┘ └──────┘  └─────────┘
typ                         └────┘        └────┘     └─────┘ └──────┘  └─────────┘    
doc                                                    └─────┘           └─────────┘
1543  tendsto_inf_left tendsto_comap
id   └──────────────┘ └───────────┘
src  └──────────────┘ └───────────┘
typ  └──────────────┘ └───────────┘
1544  
1545  lemma tendsto_snd {f : filter α} {g : filter β} : tendsto prod.snd (filter.prod f g) g :=
id                          └────┘        └────┘     └─────┘ └──────┘  └─────────┘    
src                         └────┘         └────┘      └─────┘ └──────┘  └─────────┘
typ                         └────┘        └────┘     └─────┘ └──────┘  └─────────┘    
doc                                                    └─────┘           └─────────┘
1546  tendsto_inf_right tendsto_comap
id   └───────────────┘ └───────────┘
src  └───────────────┘ └───────────┘
typ  └───────────────┘ └───────────┘
1547  
1548  lemma tendsto.prod_mk {f : filter α} {g : filter β} {h : filter γ} {m₁ : α → β} {m₂ : α → γ}
id                              └────┘        └────┘        └────┘                       
src                             └────┘         └────┘         └────┘
typ                             └────┘        └────┘        └────┘                       
1549    (h₁ : tendsto m₁ f g) (h₂ : tendsto m₂ f h) : tendsto (λx, (m₁ x, m₂ x)) f (filter.prod g h) :=
id           └─────┘ └┘          └─────┘ └┘      └─────┘     └┘   └┘      └─────────┘  
src          └─────┘               └─────┘           └─────┘                      └─────────┘
typ          └─────┘ └┘          └─────┘ └┘      └─────┘     └┘   └┘      └─────────┘  
doc          └─────┘               └─────┘           └─────┘                       └─────────┘
1550  tendsto_inf.2 ⟨tendsto_comap_iff.2 h₁, tendsto_comap_iff.2 h₂⟩
id   └─────────┘   └───────────────┘  └┘  └───────────────┘  └┘
src  └─────────┘   └───────────────┘      └───────────────┘
typ  └─────────┘   └───────────────┘  └┘  └───────────────┘  └┘
1551  
1552  lemma prod_infi_left {f : ι → filter α} {g : filter β} (i : ι) :
id                                └────┘        └────┘        
src                                └────┘         └────┘
typ                               └────┘        └────┘        
1553    filter.prod (⨅i, f i) g = (⨅i, filter.prod (f i) g) :=
id     └─────────┘          └─────────┘     
src    └─────────┘               └─────────┘
typ    └─────────┘          └─────────┘     
doc    └─────────┘                └─────────┘
1554  by rw [filter.prod, comap_infi, infi_inf i]; simp only [filter.prod, eq_self_iff_true]
id          └─────────┘  └────────┘  └──────┘               └─────────┘  └──────────────┘
src     └──┘└─────────┘└┘└────────┘└┘└──────┘   └─────────┘└─────────┘└┘└──────────────┘└─
typ     └──┘└─────────┘└┘└────────┘└┘└──────┘  └─────────┘└─────────┘└┘└──────────────┘└─
doc     └──┘└─────────┘└┘          └┘           └─────────┘└─────────┘└┘                └─
txt     └──┘           └┘          └┘           └─────────┘           └┘                └─
par     └──┘           └┘          └┘           └─────────┘           └┘                └─
pid       └┘           └┘          └┘               └──┘└┘           └┘                
st     └──────────────┘└──────────┘└──────────┘└───────────────────────────────────────────
1555  
src  
typ  
doc  
txt  
par  
pid  
st   
1556  lemma prod_infi_right {f : filter α} {g : ι → filter β} (i : ι) :
id                              └────┘           └────┘        
src                             └────┘             └────┘
typ                             └────┘           └────┘        
1557    filter.prod f (⨅i, g i) = (⨅i, filter.prod f (g i)) :=
id     └─────────┘          └─────────┘    
src    └─────────┘               └─────────┘
typ    └─────────┘          └─────────┘    
doc    └─────────┘                └─────────┘
1558  by rw [filter.prod, comap_infi, inf_infi i]; simp only [filter.prod, eq_self_iff_true]
id          └─────────┘  └────────┘  └──────┘               └─────────┘  └──────────────┘
src     └──┘└─────────┘└┘└────────┘└┘└──────┘   └─────────┘└─────────┘└┘└──────────────┘└─
typ     └──┘└─────────┘└┘└────────┘└┘└──────┘  └─────────┘└─────────┘└┘└──────────────┘└─
doc     └──┘└─────────┘└┘          └┘           └─────────┘└─────────┘└┘                └─
txt     └──┘           └┘          └┘           └─────────┘           └┘                └─
par     └──┘           └┘          └┘           └─────────┘           └┘                └─
pid       └┘           └┘          └┘               └──┘└┘           └┘                
st     └──────────────┘└──────────┘└──────────┘└───────────────────────────────────────────
1559  
src  
typ  
doc  
txt  
par  
pid  
st   
1560  lemma prod_mono {f₁ f₂ : filter α} {g₁ g₂ : filter β} (hf : f₁ ≤ f₂) (hg : g₁ ≤ g₂) :
id                            └────┘            └────┘         └┘  └┘        └┘  └┘
src                           └────┘             └────┘                           
typ                           └────┘            └────┘         └┘  └┘        └┘  └┘
1561    filter.prod f₁ g₁ ≤ filter.prod f₂ g₂ :=
id     └─────────┘ └┘ └┘  └─────────┘ └┘ └┘
src    └─────────┘        └─────────┘
typ    └─────────┘ └┘ └┘  └─────────┘ └┘ └┘
doc    └─────────┘         └─────────┘
1562  inf_le_inf (comap_mono hf) (comap_mono hg)
id   └────────┘  └────────┘ └┘   └────────┘ └┘
src  └────────┘  └────────┘      └────────┘
typ  └────────┘  └────────┘ └┘   └────────┘ └┘
1563  
1564  lemma prod_comap_comap_eq {α₁ : Type u} {α₂ : Type v} {β₁ : Type w} {β₂ : Type x}
1565    {f₁ : filter α₁} {f₂ : filter α₂} {m₁ : β₁ → α₁} {m₂ : β₂ → α₂} :
id           └────┘ └┘        └────┘ └┘        └┘   └┘        └┘   └┘
src          └────┘           └────┘
typ          └────┘ └┘        └────┘ └┘        └┘   └┘        └┘   └┘
1566    filter.prod (comap m₁ f₁) (comap m₂ f₂) = comap (λp:β₁×β₂, (m₁ p.1, m₂ p.2)) (filter.prod f₁ f₂) :=
id     └─────────┘  └───┘ └┘ └┘   └───┘ └┘ └┘   └───┘     └┘└┘  └┘    └┘      └─────────┘ └┘ └┘
src    └─────────┘  └───┘         └───┘         └───┘                           └─────────┘
typ    └─────────┘  └───┘ └┘ └┘   └───┘ └┘ └┘   └───┘     └┘└┘  └┘    └┘      └─────────┘ └┘ └┘
doc    └─────────┘  └───┘         └───┘          └───┘                               └─────────┘
1567  by simp only [filter.prod, comap_comap_comp, eq_self_iff_true, comap_inf]
id                 └─────────┘  └──────────────┘  └──────────────┘  └───────┘
src     └─────────┘└─────────┘└┘└──────────────┘└┘└──────────────┘└┘└───────┘└─
typ     └─────────┘└─────────┘└┘└──────────────┘└┘└──────────────┘└┘└───────┘└─
doc     └─────────┘└─────────┘└┘                └┘                └┘         └─
txt     └─────────┘           └┘                └┘                └┘         └─
par     └─────────┘           └┘                └┘                └┘         └─
pid         └──┘└┘           └┘                └┘                └┘         
st     └───────────────────────────────────────────────────────────────────────
1568  
src  
typ  
doc  
txt  
par  
pid  
st   
1569  lemma prod_comm' : filter.prod f g = comap (prod.swap) (filter.prod g f) :=
id                      └─────────┘    └───┘  └───────┘   └─────────┘  
src                     └─────────┘      └───┘  └───────┘   └─────────┘
typ                     └─────────┘    └───┘  └───────┘   └─────────┘  
doc                     └─────────┘       └───┘  └───────┘   └─────────┘
1570  by simp only [filter.prod, comap_comap_comp, (∘), inf_comm, prod.fst_swap,
id                 └─────────┘  └──────────────┘      └──────┘  └───────────┘
src     └─────────┘└─────────┘└┘└──────────────┘└┘└──┘└──────┘└┘└───────────┘└─
typ     └─────────┘└─────────┘└┘└──────────────┘└┘└──┘└──────┘└┘└───────────┘└─
doc     └─────────┘└─────────┘└┘                └┘ └──┘        └┘             └─
txt     └─────────┘           └┘                └┘ └──┘        └┘             └─
par     └─────────┘           └┘                └┘ └──┘        └┘             └─
pid         └──┘└┘           └┘                └┘ └──┘        └┘             └─
st     └────────────────────────────────────────────────────────────────────────
1571    eq_self_iff_true, prod.snd_swap, comap_inf]
id     └──────────────┘  └───────────┘  └───────┘
src  ─┘└──────────────┘└┘└───────────┘└┘└───────┘└─
typ  ─┘└──────────────┘└┘└───────────┘└┘└───────┘└─
doc  ─┘                └┘             └┘         └─
txt  ─┘                └┘             └┘         └─
par  ─┘                └┘             └┘         └─
pid  ─┘                └┘             └┘         
st   ──────────────────────────────────────────────
1572  
src  
typ  
doc  
txt  
par  
pid  
st   
1573  lemma prod_comm : filter.prod f g = map (λp:β×α, (p.2, p.1)) (filter.prod g f) :=
id                     └─────────┘    └─┘               └─────────┘  
src                    └─────────┘      └─┘                   └─────────┘
typ                    └─────────┘    └─┘               └─────────┘  
doc                    └─────────┘       └─┘                       └─────────┘
1574  by rw [prod_comm', ← map_swap_eq_comap_swap]; refl
id          └────────┘    └────────────────────┘
src     └──┘└────────┘└──┘└────────────────────┘  └────
typ     └──┘└────────┘└──┘└────────────────────┘  └────
doc     └──┘          └──┘                        └────
txt     └──┘          └──┘                        └────
par     └──┘          └──┘                        └────
pid       └┘          └──┘                            
st     └─────────────┘└────────────────────────┘└──────
1575  
src  
typ  
doc  
txt  
par  
pid  
st   
1576  lemma prod_map_map_eq {α₁ : Type u} {α₂ : Type v} {β₁ : Type w} {β₂ : Type x}
1577    {f₁ : filter α₁} {f₂ : filter α₂} {m₁ : α₁ → β₁} {m₂ : α₂ → β₂} :
id           └────┘ └┘        └────┘ └┘        └┘   └┘        └┘   └┘
src          └────┘           └────┘
typ          └────┘ └┘        └────┘ └┘        └┘   └┘        └┘   └┘
1578    filter.prod (map m₁ f₁) (map m₂ f₂) = map (λp:α₁×α₂, (m₁ p.1, m₂ p.2)) (filter.prod f₁ f₂) :=
id     └─────────┘  └─┘ └┘ └┘   └─┘ └┘ └┘   └─┘     └┘└┘  └┘    └┘      └─────────┘ └┘ └┘
src    └─────────┘  └─┘         └─┘         └─┘                           └─────────┘
typ    └─────────┘  └─┘ └┘ └┘   └─┘ └┘ └┘   └─┘     └┘└┘  └┘    └┘      └─────────┘ └┘ └┘
doc    └─────────┘  └─┘         └─┘          └─┘                               └─────────┘
1579  le_antisymm
id   └─────────┘
src  └─────────┘
typ  └─────────┘
1580    (assume s hs,
id              └┘
typ             └┘
1581      let ⟨s₁, hs₁, s₂, hs₂, h⟩ := mem_prod_iff.mp hs in
id       └─┘  └┘  └─┘  └┘  └─┘        └──────────┘└─┘ └┘
src                                   └──────────┘└─┘
typ      └─┘  └┘  └─┘  └┘  └─┘        └──────────┘└─┘ └┘
1582      filter.sets_of_superset _ (prod_mem_prod (image_mem_map hs₁) (image_mem_map hs₂)) $
id       └─────────────────────┘    └───────────┘  └───────────┘       └───────────┘
src      └─────────────────────┘    └───────────┘  └───────────┘       └───────────┘
typ      └─────────────────────┘    └───────────┘  └───────────┘       └───────────┘
1583        calc set.prod (m₁ '' s₁) (m₂ '' s₂) = (λp:α₁×α₂, (m₁ p.1, m₂ p.2)) '' set.prod s₁ s₂ :
id              └──────┘  └┘ └┘      └┘ └┘           └┘└┘  └┘    └┘     └┘ └──────┘
src             └──────┘     └┘         └┘                                └┘ └──────┘
typ             └──────┘  └┘ └┘      └┘ └┘           └┘└┘  └┘    └┘     └┘ └──────┘
doc             └──────┘                                                         └──────┘
1584            set.prod_image_image_eq
id             └─────────────────────┘
src            └─────────────────────┘
typ            └─────────────────────┘
1585          ... ⊆ _ : by rwa [image_subset_iff])
id                             └──────────────┘
src                       └───┘└──────────────┘
typ                       └───┘└──────────────┘
doc                       └───┘└──────────────┘
txt                       └───┘                
par                       └───┘                
pid                          └┘                
st                       └────────────────────┘
1586    ((tendsto.comp (le_refl _) tendsto_fst).prod_mk (tendsto.comp (le_refl _) tendsto_snd))
id       └──────────┘  └─────┘    └─────────┘ └─────┘   └──────────┘  └─────┘    └─────────┘
src      └──────────┘  └─────┘    └─────────┘ └─────┘   └──────────┘  └─────┘    └─────────┘
typ      └──────────┘  └─────┘    └─────────┘ └─────┘   └──────────┘  └─────┘    └─────────┘
1587  
1588  lemma map_prod (m : α × β → γ) (f : filter α) (g : filter β) :
id                                   └────┘        └────┘ 
src                                     └────┘         └────┘
typ                                  └────┘        └────┘ 
1589    map m (f.prod g) = (f.map (λa b, m (a, b))).seq g :=
id     └─┘   └───┘     └──┘            └─┘  
src    └─┘     └───┘       └──┘                 └─┘
typ    └─┘   └───┘     └──┘            └─┘  
doc    └─┘     └───┘        └──┘                  └─┘
1590  begin
st   └─────
1591    simp [filter.ext_iff, mem_prod_iff, mem_map_seq_iff],
id           └────────────┘  └──────────┘  └─────────────┘
src    └────┘└────────────┘└┘└──────────┘└┘└─────────────┘
typ    └────┘└────────────┘└┘└──────────┘└┘└─────────────┘
doc    └────┘              └┘            └┘               
txt    └────┘              └┘            └┘               
par    └────┘              └┘            └┘               
pid                      └┘            └┘               
st   ─────────────────────────────────────────────────────┘└─
1592    assume s,
src    └──────┘
typ    └──────┘
doc    └──────┘
txt    └──────┘
par    └──────┘
pid    └──────┘
st   ─────────┘└─
1593    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
1594    exact assume ⟨t, ht, s, hs, h⟩, ⟨s, hs, t, ht, assume x hx y hy, @h ⟨x, y⟩ ⟨hx, hy⟩⟩,
id                     └┘    └┘  
src    └────┘      └┘ └┘  └┘ └┘  └┘ └─┘  └┘  └┘ └┘  └┘      └──────────┘    └┘ └┘   └┘  └┘
typ    └────┘      └┘└┘└┘└┘└┘└┘└┘└─┘  └┘  └┘ └┘  └┘      └──────────┘    └┘ └┘   └┘  └┘
doc    └────┘      └┘ └┘  └┘ └┘  └┘ └─┘  └┘  └┘ └┘  └┘      └──────────┘    └┘ └┘   └┘  └┘
txt    └────┘      └┘ └┘  └┘ └┘  └┘ └─┘  └┘  └┘ └┘  └┘      └──────────┘    └┘ └┘   └┘  └┘
par    └────┘      └┘ └┘  └┘ └┘  └┘ └─┘  └┘  └┘ └┘  └┘      └──────────┘    └┘ └┘   └┘  └┘
pid               └┘ └┘  └┘ └┘  └┘ └─┘  └┘  └┘ └┘  └┘      └──────────┘    └┘ └┘   └┘  └┘
st   ─────────────────────────────────────────────────────────────────────────────────────┘└─
1595    exact assume ⟨s, hs, t, ht, h⟩, ⟨t, ht, s, hs, assume ⟨x, y⟩ ⟨hx, hy⟩, h x hx y hy⟩
id                     └┘    └┘                                 └┘  └┘
src    └────┘      └┘ └┘  └┘ └┘  └┘ └─┘  └┘  └┘ └┘  └┘      └┘ └┘ └─┘  └┘  └─┘       └┘
typ    └────┘      └┘└┘└┘└┘└┘└┘└┘└─┘  └┘  └┘ └┘  └┘      └┘└┘└─┘└┘└┘└┘└─┘       └┘
doc    └────┘      └┘ └┘  └┘ └┘  └┘ └─┘  └┘  └┘ └┘  └┘      └┘ └┘ └─┘  └┘  └─┘       └┘
txt    └────┘      └┘ └┘  └┘ └┘  └┘ └─┘  └┘  └┘ └┘  └┘      └┘ └┘ └─┘  └┘  └─┘       └┘
par    └────┘      └┘ └┘  └┘ └┘  └┘ └─┘  └┘  └┘ └┘  └┘      └┘ └┘ └─┘  └┘  └─┘       └┘
pid               └┘ └┘  └┘ └┘  └┘ └─┘  └┘  └┘ └┘  └┘      └┘ └┘ └─┘  └┘  └─┘       
st   ─────────────────────────────────────────────────────────────────────────────────────┘
1596  end
st   └─┘
1597  
1598  lemma prod_eq {f : filter α} {g : filter β} : f.prod g = (f.map prod.mk).seq g  :=
id                      └────┘        └────┘     └───┘    └──┘ └─────┘ └─┘  
src                     └────┘         └────┘       └───┘      └──┘ └─────┘ └─┘
typ                     └────┘        └────┘     └───┘    └──┘ └─────┘ └─┘  
doc                                                 └───┘       └──┘         └─┘
1599  have h : _ := map_prod id f g, by rwa [map_id] at h
id                 └──────┘ └┘            └────┘
src                └──────┘ └┘         └───┘└────┘└──────
typ                └──────┘ └┘       └───┘└────┘└──────
doc                                    └───┘      └──────
txt                                    └───┘      └──────
par                                    └───┘      └──────
pid                                       └┘      └───┘
st                                    └──────────┘└─────
1600  
src  
typ  
doc  
txt  
par  
pid  
st   
1601  lemma prod_inf_prod {f₁ f₂ : filter α} {g₁ g₂ : filter β} :
id                                └────┘            └────┘ 
src                               └────┘             └────┘
typ                               └────┘            └────┘ 
1602    filter.prod f₁ g₁ ⊓ filter.prod f₂ g₂ = filter.prod (f₁ ⊓ f₂) (g₁ ⊓ g₂) :=
id     └─────────┘ └┘ └┘  └─────────┘ └┘ └┘  └─────────┘  └┘  └┘   └┘  └┘
src    └─────────┘        └─────────┘        └─────────┘              
typ    └─────────┘ └┘ └┘  └─────────┘ └┘ └┘  └─────────┘  └┘  └┘   └┘  └┘
doc    └─────────┘         └─────────┘         └─────────┘
1603  by simp only [filter.prod, comap_inf, inf_comm, inf_assoc, lattice.inf_left_comm]
id                 └─────────┘  └───────┘  └──────┘  └───────┘  └───────────────────┘
src     └─────────┘└─────────┘└┘└───────┘└┘└──────┘└┘└───────┘└┘└───────────────────┘└─
typ     └─────────┘└─────────┘└┘└───────┘└┘└──────┘└┘└───────┘└┘└───────────────────┘└─
doc     └─────────┘└─────────┘└┘         └┘        └┘         └┘                     └─
txt     └─────────┘           └┘         └┘        └┘         └┘                     └─
par     └─────────┘           └┘         └┘        └┘         └┘                     └─
pid         └──┘└┘           └┘         └┘        └┘         └┘                     
st     └───────────────────────────────────────────────────────────────────────────────
1604  
src  
typ  
doc  
txt  
par  
pid  
st   
1605  @[simp] lemma prod_bot {f : filter α} : filter.prod f (⊥ : filter β) = ⊥ := by simp [filter.prod]
id                               └────┘     └─────────┘      └────┘                 └─────────┘
src                              └────┘      └─────────┘       └────┘            └────┘└─────────┘└┘
typ                              └────┘     └─────────┘      └────┘           └────┘└─────────┘└┘
doc    └──┘                                  └─────────┘                            └────┘└─────────┘└┘
txt                                                                                 └────┘           └┘
par                                                                                 └────┘           └┘
pid                                                                                                
st                                                                                 └──────────────────┘
1606  @[simp] lemma bot_prod {g : filter β} : filter.prod (⊥ : filter α) g = ⊥ := by simp [filter.prod]
id                               └────┘     └─────────┘     └────┘                  └─────────┘
src                              └────┘      └─────────┘     └────┘              └────┘└─────────┘└─
typ                              └────┘     └─────────┘     └────┘            └────┘└─────────┘└─
doc    └──┘                                  └─────────┘                            └────┘└─────────┘└─
txt                                                                                 └────┘           └─
par                                                                                 └────┘           └─
pid                                                                                                
st                                                                                 └───────────────────
1607  
src  
typ  
doc  
txt  
par  
pid  
st   
1608  @[simp] lemma prod_principal_principal {s : set α} {t : set β} :
id                                               └─┘        └─┘ 
src                                              └─┘         └─┘
typ                                              └─┘        └─┘ 
doc    └──┘
1609    filter.prod (principal s) (principal t) = principal (set.prod s t) :=
id     └─────────┘  └───────┘    └───────┘    └───────┘  └──────┘  
src    └─────────┘  └───────┘     └───────┘     └───────┘  └──────┘
typ    └─────────┘  └───────┘    └───────┘    └───────┘  └──────┘  
doc    └─────────┘  └───────┘     └───────┘      └───────┘  └──────┘
1610  by simp only [filter.prod, comap_principal, principal_eq_iff_eq, comap_principal, inf_principal]; refl
id                 └─────────┘  └─────────────┘  └─────────────────┘  └─────────────┘  └───────────┘
src     └─────────┘└─────────┘└┘└─────────────┘└┘└─────────────────┘└┘└─────────────┘└┘└───────────┘  └────
typ     └─────────┘└─────────┘└┘└─────────────┘└┘└─────────────────┘└┘└─────────────┘└┘└───────────┘  └────
doc     └─────────┘└─────────┘└┘               └┘                   └┘               └┘               └────
txt     └─────────┘           └┘               └┘                   └┘               └┘               └────
par     └─────────┘           └┘               └┘                   └┘               └┘               └────
pid         └──┘└┘           └┘               └┘                   └┘               └┘                   
st     └────────────────────────────────────────────────────────────────────────────────────────────────────
1611  
src  
typ  
doc  
txt  
par  
pid  
st   
1612  @[simp] lemma prod_pure_pure {a : α} {b : β} : filter.prod (pure a) (pure b) = pure (a, b) :=
id                                                └─────────┘  └──┘    └──┘    └──┘   
src                                                 └─────────┘  └──┘     └──┘     └──┘ 
typ                                               └─────────┘  └──┘    └──┘    └──┘   
doc    └──┘                                         └─────────┘
st     └──┘
1613  by simp [pure_eq_principal]
id            └───────────────┘
src     └────┘└───────────────┘└─
typ     └────┘└───────────────┘└─
doc     └────┘                 └─
txt     └────┘                 └─
par     └────┘                 └─
pid                          
st     └─────────────────────────
1614  
src  
typ  
doc  
txt  
par  
pid  
st   
1615  lemma prod_eq_bot {f : filter α} {g : filter β} : filter.prod f g = ⊥ ↔ (f = ⊥ ∨ g = ⊥) :=
id                          └────┘        └────┘     └─────────┘             
src                         └────┘         └────┘      └─────────┘                 
typ                         └────┘        └────┘     └─────────┘             
doc                                                    └─────────┘
1616  begin
st   └─────
1617    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
1618    { assume h,
src      └──────┘
typ      └──────┘
doc      └──────┘
txt      └──────┘
par      └──────┘
pid      └──────┘
st   ───┘└──────┘└─
1619      rcases mem_prod_iff.1 (empty_in_sets_eq_bot.2 h) with ⟨s, hs, t, ht, hst⟩,
id              └──────────┘    └──────────────────┘   
src      └─────┘└──────────┘└─┘ └──────────────────┘└─┘ └────────────────────────┘
typ      └─────┘└──────────┘└─┘ └──────────────────┘└─┘└────────────────────────┘
doc      └─────┘            └─┘                     └─┘ └────────────────────────┘
txt      └─────┘            └─┘                     └─┘ └────────────────────────┘
par      └─────┘            └─┘                     └─┘ └────────────────────────┘
pid                        └─┘                     └─┘ └────────────────────────┘
st   ────────────────────────────────────────────────────────────────────────────┘└─
1620      rw [subset_empty_iff, set.prod_eq_empty_iff] at hst,
id           └──────────────┘  └───────────────────┘
src      └──┘└──────────────┘└┘└───────────────────┘└──────┘
typ      └──┘└──────────────┘└┘└───────────────────┘└──────┘
doc      └──┘                └┘                     └──────┘
txt      └──┘                └┘                     └──────┘
par      └──┘                └┘                     └──────┘
pid        └┘                └┘                     └─────┘
st   ───────────────────────┘└─────────────────────┘└─────┘└─
1621      cases hst with s_eq t_eq,
id             └─┘
src      └────┘   └─────────────┘
typ      └────┘└─┘└─────────────┘
doc      └────┘   └─────────────┘
txt      └────┘   └─────────────┘
par      └────┘   └─────────────┘
pid              └─────────────┘
st   ───────────────────────────┘└─
1622      { left, exact empty_in_sets_eq_bot.1 (s_eq ▸ hs) },
id                     └──────────────────┘    └──┘  └┘
src        └──┘  └────┘└──────────────────┘└─┘       └┘
typ        └──┘  └────┘└──────────────────┘└─┘ └──┘└┘└┘
doc        └──┘  └────┘                    └─┘        └┘
txt        └──┘  └────┘                    └─┘        └┘
par        └──┘  └────┘                    └─┘        └┘
pid                                       └─┘        
st   ─────┘└──┘└─────────────────────────────────────────┘└┘
1623      { right, exact empty_in_sets_eq_bot.1 (t_eq ▸ ht) } },
id                      └──────────────────┘    └──┘   └┘
src        └───┘  └────┘└──────────────────┘└─┘        └┘
typ        └───┘  └────┘└──────────────────┘└─┘ └──┘ └┘└┘
doc        └───┘  └────┘                    └─┘        └┘
txt        └───┘  └────┘                    └─┘        └┘
par        └───┘  └────┘                    └─┘        └┘
pid                                        └─┘        
st   ──────────┘└─────────────────────────────────────────┘└──┘
1624    { rintros (rfl | rfl),
src      └─────────────────┘
typ      └─────────────────┘
doc      └─────────────────┘
txt      └─────────────────┘
par      └─────────────────┘
pid             └──────────┘
st   ──────────────────────┘└─
1625      exact bot_prod,
id             └──────┘
src      └────┘└──────┘
typ      └────┘└──────┘
doc      └────┘
txt      └────┘
par      └────┘
pid           
st   ─────────────────┘└─
1626      exact prod_bot }
id             └──────┘
src      └────┘└──────┘
typ      └────┘└──────┘
doc      └────┘        
txt      └────┘        
par      └────┘        
pid                   
st   ──────────────────┘└─
1627  end
st   ──┘
1628  
1629  lemma prod_ne_bot {f : filter α} {g : filter β} : filter.prod f g ≠ ⊥ ↔ (f ≠ ⊥ ∧ g ≠ ⊥) :=
id                          └────┘        └────┘     └─────────┘             
src                         └────┘         └────┘      └─────────┘                 
typ                         └────┘        └────┘     └─────────┘             
doc                                                    └─────────┘
1630  by rw [(≠), prod_eq_bot, not_or_distrib]
id              └─────────┘  └────────────┘
src     └──┘└──┘└─────────┘└┘└────────────┘└─
typ     └──┘└──┘└─────────┘└┘└────────────┘└─
doc     └──┘ └──┘           └┘              └─
txt     └──┘ └──┘           └┘              └─
par     └──┘ └──┘           └┘              └─
pid       └┘ └──┘           └┘              
st     └──────┘└───────────┘└──────────────┘
1631  
src  
typ  
doc  
txt  
par  
pid  
st   
1632  lemma tendsto_prod_iff {f : α × β → γ} {x : filter α} {y : filter β} {z : filter γ} :
id                                           └────┘        └────┘        └────┘ 
src                                             └────┘         └────┘         └────┘
typ                                          └────┘        └────┘        └────┘ 
1633    filter.tendsto f (filter.prod x y) z ↔
id     └────────────┘   └─────────┘     
src    └────────────┘    └─────────┘        
typ    └────────────┘   └─────────┘     
doc    └────────────┘    └─────────┘
1634    ∀ W ∈ z, ∃ U ∈ x,  ∃ V ∈ y, ∀ x y, x ∈ U → y ∈ V → f (x, y) ∈ W :=
id                                            
src                                                         
typ                                           
1635  by simp only [tendsto_def, mem_prod_iff, prod_sub_preimage_iff, exists_prop, iff_self]
id                 └─────────┘  └──────────┘  └───────────────────┘  └─────────┘  └──────┘
src     └─────────┘└─────────┘└┘└──────────┘└┘└───────────────────┘└┘└─────────┘└┘└──────┘└─
typ     └─────────┘└─────────┘└┘└──────────┘└┘└───────────────────┘└┘└─────────┘└┘└──────┘└─
doc     └─────────┘           └┘            └┘                     └┘           └┘        └─
txt     └─────────┘           └┘            └┘                     └┘           └┘        └─
par     └─────────┘           └┘            └┘                     └┘           └┘        └─
pid         └──┘└┘           └┘            └┘                     └┘           └┘        
st     └────────────────────────────────────────────────────────────────────────────────────
1636  
src  
typ  
doc  
txt  
par  
pid  
st   
1637  end prod
1638  
1639  /- at_top and at_bot -/
1640  
1641  /-- `at_top` is the filter representing the limit `→ ∞` on an ordered set.
1642    It is generated by the collection of up-sets `{b | a ≤ b}`.
1643    (The preorder need not have a top element for this to be well defined,
1644    and indeed is trivial when a top element exists.) -/
1645  def at_top [preorder α] : filter α := ⨅ a, principal {b | a ≤ b}
id               └──────┘     └────┘       └───────┘      
src              └──────┘      └────┘         └───────┘       
typ              └──────┘     └────┘       └───────┘      
doc                                           └───────┘
1646  
1647  /-- `at_bot` is the filter representing the limit `→ -∞` on an ordered set.
1648    It is generated by the collection of down-sets `{b | b ≤ a}`.
1649    (The preorder need not have a bottom element for this to be well defined,
1650    and indeed is trivial when a bottom element exists.) -/
1651  def at_bot [preorder α] : filter α := ⨅ a, principal {b | b ≤ a}
id               └──────┘     └────┘       └───────┘      
src              └──────┘      └────┘         └───────┘       
typ              └──────┘     └────┘       └───────┘      
doc                                           └───────┘
1652  
1653  lemma mem_at_top [preorder α] (a : α) : {b : α | a ≤ b} ∈ @at_top α _ :=
id                     └──────┘                         └────┘ 
src                    └──────┘                              └────┘
typ                    └──────┘                         └────┘ 
doc                                                             └────┘
1654  mem_infi_sets a $ subset.refl _
id   └───────────┘    └─────────┘
src  └───────────┘     └─────────┘
typ  └───────────┘    └─────────┘
1655  
1656  @[simp] lemma at_top_ne_bot [nonempty α] [semilattice_sup α] : (at_top : filter α) ≠ ⊥ :=
id                                └──────┘    └─────────────┘      └────┘   └────┘    
src                               └──────┘     └─────────────┘       └────┘   └────┘     
typ                               └──────┘    └─────────────┘      └────┘   └────┘    
doc    └──┘                                    └─────────────┘       └────┘
1657  infi_ne_bot_of_directed (by apply_instance)
id   └─────────────────────┘
src  └─────────────────────┘     └────────────┘
typ  └─────────────────────┘     └────────────┘
doc  └─────────────────────┘     └────────────┘
txt                              └────────────┘
par                              └────────────┘
st                              └─────────────┘
1658    (assume a b, ⟨a ⊔ b, by simp only [ge, le_principal_iff, forall_const, set_of_subset_set_of,
id                                   └┘  └──────────────┘  └──────────┘  └──────────────────┘
src                           └─────────┘└┘└┘└──────────────┘└┘└──────────┘└┘└──────────────────┘└─
typ                       └─────────┘└┘└┘└──────────────┘└┘└──────────┘└┘└──────────────────┘└─
doc                            └─────────┘  └┘                └┘            └┘                    └─
txt                            └─────────┘  └┘                └┘            └┘                    └─
par                            └─────────┘  └┘                └┘            └┘                    └─
pid                                └──┘└┘  └┘                └┘            └┘                    └─
st                            └─────────────────────────────────────────────────────────────────────
1659      mem_principal_sets, and_self, sup_le_iff, forall_true_iff] {contextual := tt}⟩)
id       └────────────────┘  └──────┘  └────────┘  └─────────────┘                 └┘
src  ───┘└────────────────┘└┘└──────┘└┘└────────┘└┘└─────────────┘└┘ └────────────┘└┘
typ  ───┘└────────────────┘└┘└──────┘└┘└────────┘└┘└─────────────┘└┘ └────────────┘└┘
doc  ───┘                  └┘        └┘          └┘               └┘ └────────────┘  
txt  ───┘                  └┘        └┘          └┘               └┘ └────────────┘  
par  ───┘                  └┘        └┘          └┘               └┘ └────────────┘  
pid  ───┘                  └┘        └┘          └┘                └────────────┘  
st   ────────────────────────────────────────────────────────────────────────────────┘
1660    (assume a, principal_ne_bot_iff.2 nonempty_Ici)
id               └──────────────────┘  └──────────┘
src               └──────────────────┘  └──────────┘
typ              └──────────────────┘  └──────────┘
1661  
1662  @[simp] lemma mem_at_top_sets [nonempty α] [semilattice_sup α] {s : set α} :
id                                  └──────┘    └─────────────┘        └─┘ 
src                                 └──────┘     └─────────────┘         └─┘
typ                                 └──────┘    └─────────────┘        └─┘ 
doc    └──┘                                      └─────────────┘
1663    s ∈ (at_top : filter α) ↔ ∃a:α, ∀b≥a, b ∈ s :=
id        └────┘   └────┘             
src        └────┘   └────┘                
typ       └────┘   └────┘             
doc         └────┘
1664  let ⟨a⟩ := ‹nonempty α› in
id   └─┘       └──────┘ 
src             └──────┘  
typ  └─┘       └──────┘ 
doc                       
1665  iff.intro
id   └───────┘
src  └───────┘
typ  └───────┘
1666    (assume h, infi_sets_induct h ⟨a, by simp only [forall_const, mem_univ, forall_true_iff]⟩
id               └──────────────┘                    └──────────┘  └──────┘  └─────────────┘
src               └──────────────┘          └─────────┘└──────────┘└┘└──────┘└┘└─────────────┘
typ              └──────────────┘         └─────────┘└──────────┘└┘└──────┘└┘└─────────────┘
doc                                         └─────────┘            └┘        └┘               
txt                                         └─────────┘            └┘        └┘               
par                                         └─────────┘            └┘        └┘               
pid                                             └──┘└┘            └┘        └┘               
st                                         └──────────────────────────────────────────────────┘
1667      (assume a s₁ s₂ ha ⟨b, hb⟩, ⟨a ⊔ b,
id                └┘ └┘ └┘   └┘     
src                                     
typ               └┘ └┘ └┘   └┘     
1668        assume c hc, ⟨ha $ le_trans le_sup_left hc, hb _ $ le_trans le_sup_right hc⟩⟩)
id                 └┘   └┘   └──────┘ └─────────┘ └┘         └──────┘ └──────────┘ └┘
src                           └──────┘ └─────────┘            └──────┘ └──────────┘
typ                └┘   └┘   └──────┘ └─────────┘ └┘         └──────┘ └──────────┘ └┘
1669      (assume s₁ s₂ h ⟨a, ha⟩, ⟨a, assume b hb, h $ ha _ hb⟩))
id               └┘ └┘    └┘               └┘          └┘
typ              └┘ └┘    └┘               └┘          └┘
1670    (assume ⟨a, h⟩, mem_infi_sets a $ assume x, h x)
id                  └───────────┘                
src                    └───────────┘
typ                 └───────────┘                
1671  
1672  @[nolint] -- ≥
doc    └────┘
1673  lemma eventually_at_top {α} [semilattice_sup α] [nonempty α] {p : α → Prop} :
id                                └─────────────┘    └──────┘        
src                               └─────────────┘     └──────┘
typ                               └─────────────┘    └──────┘        
doc                               └─────────────┘
1674    (∀ᶠ x in at_top, p x) ↔ (∃ a, ∀ b ≥ a, p b) :=
id      └┘  └┘ └────┘                
src     └┘   └┘ └────┘          
typ     └┘  └┘ └────┘                
doc     └┘   └┘ └────┘
1675  by simp only [filter.eventually, filter.mem_at_top_sets, mem_set_of_eq]
id                 └───────────────┘  └────────────────────┘  └───────────┘
src     └─────────┘└───────────────┘└┘└────────────────────┘└┘└───────────┘└─
typ     └─────────┘└───────────────┘└┘└────────────────────┘└┘└───────────┘└─
doc     └─────────┘└───────────────┘└┘                      └┘             └─
txt     └─────────┘                 └┘                      └┘             └─
par     └─────────┘                 └┘                      └┘             └─
pid         └──┘└┘                 └┘                      └┘             
st     └─────────────────────────────────────────────────────────────────────
1676  
src  
typ  
doc  
txt  
par  
pid  
st   
1677  @[nolint] -- ≥
doc    └────┘
1678  lemma eventually.exists_forall_of_at_top {α} [semilattice_sup α] [nonempty α] {p : α → Prop}
id                                                 └─────────────┘    └──────┘        
src                                                └─────────────┘     └──────┘
typ                                                └─────────────┘    └──────┘        
doc                                                └─────────────┘
1679    (h : ∀ᶠ x in at_top, p x) : ∃ a, ∀ b ≥ a, p b :=
id          └┘  └┘ └────┘                
src         └┘   └┘ └────┘          
typ         └┘  └┘ └────┘                
doc         └┘   └┘ └────┘
1680  eventually_at_top.mp h
id   └───────────────┘└─┘ 
src  └───────────────┘└─┘
typ  └───────────────┘└─┘ 
1681  
1682  @[nolint] -- ≥
doc    └────┘
1683  lemma frequently_at_top {α} [semilattice_sup α] [nonempty α] {p : α → Prop} :
id                                └─────────────┘    └──────┘        
src                               └─────────────┘     └──────┘
typ                               └─────────────┘    └──────┘        
doc                               └─────────────┘
1684    (∃ᶠ x in at_top, p x) ↔ (∀ a, ∃ b ≥ a, p b) :=
id      └┘  └┘ └────┘                
src     └┘   └┘ └────┘                   
typ     └┘  └┘ └────┘                
doc     └┘   └┘ └────┘
1685  by simp only [filter.frequently, eventually_at_top, not_exists, not_forall, not_not]
id                 └───────────────┘  └───────────────┘  └────────┘  └────────┘  └─────┘
src     └─────────┘└───────────────┘└┘└───────────────┘└┘└────────┘└┘└────────┘└┘└─────┘└─
typ     └─────────┘└───────────────┘└┘└───────────────┘└┘└────────┘└┘└────────┘└┘└─────┘└─
doc     └─────────┘└───────────────┘└┘                 └┘          └┘          └┘       └─
txt     └─────────┘                 └┘                 └┘          └┘          └┘       └─
par     └─────────┘                 └┘                 └┘          └┘          └┘       └─
pid         └──┘└┘                 └┘                 └┘          └┘          └┘       
st     └──────────────────────────────────────────────────────────────────────────────────
1686  
src  
typ  
doc  
txt  
par  
pid  
st   
1687  @[nolint] -- ≥
doc    └────┘
1688  lemma frequently.forall_exists_of_at_top {α} [semilattice_sup α] [nonempty α] {p : α → Prop}
id                                                 └─────────────┘    └──────┘        
src                                                └─────────────┘     └──────┘
typ                                                └─────────────┘    └──────┘        
doc                                                └─────────────┘
1689    (h : ∃ᶠ x in at_top, p x) : ∀ a, ∃ b ≥ a, p b :=
id          └┘  └┘ └────┘                
src         └┘   └┘ └────┘                   
typ         └┘  └┘ └────┘                
doc         └┘   └┘ └────┘
1690  frequently_at_top.mp h
id   └───────────────┘└─┘ 
src  └───────────────┘└─┘
typ  └───────────────┘└─┘ 
1691  
1692  lemma map_at_top_eq [nonempty α] [semilattice_sup α] {f : α → β} :
id                        └──────┘    └─────────────┘           
src                       └──────┘     └─────────────┘
typ                       └──────┘    └─────────────┘           
doc                                    └─────────────┘
1693    at_top.map f = (⨅a, principal $ f '' {a' | a ≤ a'}) :=
id     └────┘└──┘     └───────┘    └┘ └┘     └┘
src    └────┘└──┘       └───────┘     └┘        
typ    └────┘└──┘     └───────┘    └┘ └┘     └┘
doc    └────┘└──┘        └───────┘
1694  calc map f (⨅a, principal {a' | a ≤ a'}) = (⨅a, map f $ principal {a' | a ≤ a'}) :
id        └─┘    └───────┘ └┘     └┘       └─┘    └───────┘ └┘     └┘
src       └─┘      └───────┘                   └─┘     └───────┘        
typ       └─┘    └───────┘ └┘     └┘       └─┘    └───────┘ └┘     └┘
doc       └─┘      └───────┘                     └─┘     └───────┘
1695      map_infi_eq (assume a b, ⟨a ⊔ b, by simp only [ge, le_principal_iff, forall_const, set_of_subset_set_of,
id       └─────────┘                               └┘  └──────────────┘  └──────────┘  └──────────────────┘
src      └─────────┘                        └─────────┘└┘└┘└──────────────┘└┘└──────────┘└┘└──────────────────┘└─
typ      └─────────┘                    └─────────┘└┘└┘└──────────────┘└┘└──────────┘└┘└──────────────────┘└─
doc                                          └─────────┘  └┘                └┘            └┘                    └─
txt                                          └─────────┘  └┘                └┘            └┘                    └─
par                                          └─────────┘  └┘                └┘            └┘                    └─
pid                                              └──┘└┘  └┘                └┘            └┘                    └─
st                                          └─────────────────────────────────────────────────────────────────────
1696        mem_principal_sets, and_self, sup_le_iff, forall_true_iff] {contextual := tt}⟩)
id         └────────────────┘  └──────┘  └────────┘  └─────────────┘                 └┘
src  ─────┘└────────────────┘└┘└──────┘└┘└────────┘└┘└─────────────┘└┘ └────────────┘└┘
typ  ─────┘└────────────────┘└┘└──────┘└┘└────────┘└┘└─────────────┘└┘ └────────────┘└┘
doc  ─────┘                  └┘        └┘          └┘               └┘ └────────────┘  
txt  ─────┘                  └┘        └┘          └┘               └┘ └────────────┘  
par  ─────┘                  └┘        └┘          └┘               └┘ └────────────┘  
pid  ─────┘                  └┘        └┘          └┘                └────────────┘  
st   ──────────────────────────────────────────────────────────────────────────────────┘
1697        (by apply_instance)
src            └────────────┘
typ            └────────────┘
doc            └────────────┘
txt            └────────────┘
par            └────────────┘
st            └─────────────┘
1698    ... = (⨅a, principal $ f '' {a' | a ≤ a'}) : by simp only [map_principal, eq_self_iff_true]
id             └───────┘    └┘ └┘     └┘                   └───────────┘  └──────────────┘
src             └───────┘     └┘                   └─────────┘└───────────┘└┘└──────────────┘└─
typ            └───────┘    └┘ └┘     └┘        └─────────┘└───────────┘└┘└──────────────┘└─
doc             └───────┘                            └─────────┘             └┘                └─
txt                                                    └─────────┘             └┘                └─
par                                                    └─────────┘             └┘                └─
pid                                                        └──┘└┘             └┘                
st                                                    └────────────────────────────────────────────
1699  
src  
typ  
doc  
txt  
par  
pid  
st   
1700  lemma tendsto_at_top [preorder β] (m : α → β) (f : filter α) :
id                         └──────┘                  └────┘ 
src                        └──────┘                     └────┘
typ                        └──────┘                  └────┘ 
1701    tendsto m f at_top ↔ (∀b, {a | b ≤ m a} ∈ f) :=
id     └─────┘   └────┘               
src    └─────┘     └────┘                   
typ    └─────┘   └────┘               
doc    └─────┘     └────┘
1702  by simp only [at_top, tendsto_infi, tendsto_principal]; refl
id                 └────┘  └──────────┘  └───────────────┘
src     └─────────┘└────┘└┘└──────────┘└┘└───────────────┘  └────
typ     └─────────┘└────┘└┘└──────────┘└┘└───────────────┘  └────
doc     └─────────┘└────┘└┘            └┘                   └────
txt     └─────────┘      └┘            └┘                   └────
par     └─────────┘      └┘            └┘                   └────
pid         └──┘└┘      └┘            └┘                       
st     └──────────────────────────────────────────────────────────
1703  
src  
typ  
doc  
txt  
par  
pid  
st   
1704  lemma tendsto_at_top_mono' [preorder β] (l : filter α) ⦃f₁ f₂ : α → β⦄ (h : {x | f₁ x ≤ f₂ x} ∈ l) :
id                               └──────┘        └────┘                         └┘   └┘    
src                              └──────┘         └────┘                                         
typ                              └──────┘        └────┘                         └┘   └┘    
1705    tendsto f₁ l at_top → tendsto f₂ l at_top :=
id     └─────┘ └┘  └────┘   └─────┘ └┘  └────┘
src    └─────┘      └────┘   └─────┘      └────┘
typ    └─────┘ └┘  └────┘   └─────┘ └┘  └────┘
doc    └─────┘      └────┘   └─────┘      └────┘
1706  assume h₁, (tendsto_at_top _ _).2 $ λ b, mp_sets ((tendsto_at_top _ _).1 h₁ b)
id          └┘   └────────────┘             └─────┘   └────────────┘       └┘ 
src              └────────────┘              └─────┘   └────────────┘     
typ         └┘   └────────────┘             └─────┘   └────────────┘       └┘ 
1707    (monotone_mem_sets (λ a ha ha₁, le_trans ha₁ ha) h)
id      └───────────────┘     └┘ └─┘  └──────┘ └─┘ └┘  
src     └───────────────┘              └──────┘
typ     └───────────────┘     └┘ └─┘  └──────┘ └─┘ └┘  
1708  
1709  lemma tendsto_at_top_mono [preorder β] (l : filter α) :
id                              └──────┘        └────┘ 
src                             └──────┘         └────┘
typ                             └──────┘        └────┘ 
1710    monotone (λ f : α → β, tendsto f l at_top) :=
id     └──────┘            └─────┘   └────┘
src    └──────┘               └─────┘     └────┘
typ    └──────┘            └─────┘   └────┘
doc    └──────┘               └─────┘     └────┘
1711  λ f₁ f₂ h, tendsto_at_top_mono' l $ univ_mem_sets' h
id     └┘ └┘   └──────────────────┘    └────────────┘ 
src             └──────────────────┘     └────────────┘
typ    └┘ └┘   └──────────────────┘    └────────────┘ 
1712  
1713  section ordered_monoid
1714  
1715  variables [ordered_cancel_comm_monoid β] (l : filter α) {f g : α → β}
id              └────────────────────────┘         └────┘
src             └────────────────────────┘         └────┘
typ             └────────────────────────┘         └────┘
1716  
1717  lemma tendsto_at_top_add_nonneg_left' (hf : {x | 0 ≤ f x} ∈ l) (hg : tendsto g l at_top) :
id                                                                 └─────┘   └────┘
src                                                                    └─────┘     └────┘
typ                                                                └─────┘   └────┘
doc                                                                       └─────┘     └────┘
1718    tendsto (λ x, f x + g x) l at_top :=
id     └─────┘             └────┘
src    └─────┘                   └────┘
typ    └─────┘             └────┘
doc    └─────┘                    └────┘
1719  tendsto_at_top_mono' l (monotone_mem_sets (λ x, le_add_of_nonneg_left) hf) hg
id   └──────────────────┘   └───────────────┘      └───────────────────┘  └┘  └┘
src  └──────────────────┘    └───────────────┘       └───────────────────┘
typ  └──────────────────┘   └───────────────┘      └───────────────────┘  └┘  └┘
1720  
1721  lemma tendsto_at_top_add_nonneg_left (hf : ∀ x, 0 ≤ f x) (hg : tendsto g l at_top) :
id                                                              └─────┘   └────┘
src                                                                └─────┘     └────┘
typ                                                             └─────┘   └────┘
doc                                                                 └─────┘     └────┘
1722    tendsto (λ x, f x + g x) l at_top :=
id     └─────┘             └────┘
src    └─────┘                   └────┘
typ    └─────┘             └────┘
doc    └─────┘                    └────┘
1723  tendsto_at_top_add_nonneg_left' l (univ_mem_sets' hf) hg
id   └─────────────────────────────┘   └────────────┘ └┘  └┘
src  └─────────────────────────────┘    └────────────┘
typ  └─────────────────────────────┘   └────────────┘ └┘  └┘
1724  
1725  lemma tendsto_at_top_add_nonneg_right' (hf : tendsto f l at_top) (hg : {x | 0 ≤ g x} ∈ l) :
id                                                └─────┘   └────┘                  
src                                               └─────┘     └────┘                    
typ                                               └─────┘   └────┘                  
doc                                               └─────┘     └────┘
1726    tendsto (λ x, f x + g x) l at_top :=
id     └─────┘             └────┘
src    └─────┘                   └────┘
typ    └─────┘             └────┘
doc    └─────┘                    └────┘
1727  tendsto_at_top_mono' l (monotone_mem_sets (λ x, le_add_of_nonneg_right) hg) hf
id   └──────────────────┘   └───────────────┘      └────────────────────┘  └┘  └┘
src  └──────────────────┘    └───────────────┘       └────────────────────┘
typ  └──────────────────┘   └───────────────┘      └────────────────────┘  └┘  └┘
1728  
1729  lemma tendsto_at_top_add_nonneg_right (hf : tendsto f l at_top) (hg : ∀ x, 0 ≤ g x) :
id                                               └─────┘   └────┘                
src                                              └─────┘     └────┘               
typ                                              └─────┘   └────┘                
doc                                              └─────┘     └────┘
1730    tendsto (λ x, f x + g x) l at_top :=
id     └─────┘             └────┘
src    └─────┘                   └────┘
typ    └─────┘             └────┘
doc    └─────┘                    └────┘
1731  tendsto_at_top_add_nonneg_right' l hf (univ_mem_sets' hg)
id   └──────────────────────────────┘  └┘  └────────────┘ └┘
src  └──────────────────────────────┘       └────────────┘
typ  └──────────────────────────────┘  └┘  └────────────┘ └┘
1732  
1733  lemma tendsto_at_top_of_add_const_left (C : β) (hf : tendsto (λ x, C + f x) l at_top) :
id                                                       └─────┘            └────┘
src                                                       └─────┘                 └────┘
typ                                                      └─────┘            └────┘
doc                                                       └─────┘                  └────┘
1734    tendsto f l at_top :=
id     └─────┘   └────┘
src    └─────┘     └────┘
typ    └─────┘   └────┘
doc    └─────┘     └────┘
1735  (tendsto_at_top _ l).2 $ assume b,
id    └────────────┘               
src   └────────────┘     
typ   └────────────┘               
1736    monotone_mem_sets (λ x, le_of_add_le_add_left) ((tendsto_at_top _ _).1 hf (C + b))
id     └───────────────┘      └───────────────────┘    └────────────┘       └┘    
src    └───────────────┘       └───────────────────┘    └────────────┘             
typ    └───────────────┘      └───────────────────┘    └────────────┘       └┘    
1737  
1738  lemma tendsto_at_top_of_add_const_right (C : β) (hf : tendsto (λ x, f x + C) l at_top) :
id                                                        └─────┘            └────┘
src                                                        └─────┘                 └────┘
typ                                                       └─────┘            └────┘
doc                                                        └─────┘                  └────┘
1739    tendsto f l at_top :=
id     └─────┘   └────┘
src    └─────┘     └────┘
typ    └─────┘   └────┘
doc    └─────┘     └────┘
1740  (tendsto_at_top _ l).2 $ assume b,
id    └────────────┘               
src   └────────────┘     
typ   └────────────┘               
1741    monotone_mem_sets (λ x, le_of_add_le_add_right) ((tendsto_at_top _ _).1 hf (b + C))
id     └───────────────┘      └────────────────────┘    └────────────┘       └┘    
src    └───────────────┘       └────────────────────┘    └────────────┘             
typ    └───────────────┘      └────────────────────┘    └────────────┘       └┘    
1742  
1743  lemma tendsto_at_top_of_add_bdd_above_left' (C) (hC : {x | f x ≤ C} ∈ l)
id                                                                  
src                                                                    
typ                                                                 
1744    (h : tendsto (λ x, f x + g x) l at_top) :
id          └─────┘             └────┘
src         └─────┘                   └────┘
typ         └─────┘             └────┘
doc         └─────┘                    └────┘
1745    tendsto g l at_top :=
id     └─────┘   └────┘
src    └─────┘     └────┘
typ    └─────┘   └────┘
doc    └─────┘     └────┘
1746  tendsto_at_top_of_add_const_left l C
id   └──────────────────────────────┘  
src  └──────────────────────────────┘
typ  └──────────────────────────────┘  
1747    (tendsto_at_top_mono' l (monotone_mem_sets (λ x (hx : f x ≤ C), add_le_add_right hx (g x)) hC) h)
id      └──────────────────┘   └───────────────┘                 └──────────────┘ └┘      └┘  
src     └──────────────────┘    └───────────────┘                     └──────────────┘
typ     └──────────────────┘   └───────────────┘                 └──────────────┘ └┘      └┘  
1748  
1749  lemma tendsto_at_top_of_add_bdd_above_left (C) (hC : ∀ x, f x ≤ C) :
id                                                               
src                                                                
typ                                                              
1750    tendsto (λ x, f x + g x) l at_top → tendsto g l at_top :=
id     └─────┘             └────┘   └─────┘   └────┘
src    └─────┘                   └────┘   └─────┘     └────┘
typ    └─────┘             └────┘   └─────┘   └────┘
doc    └─────┘                    └────┘   └─────┘     └────┘
1751  tendsto_at_top_of_add_bdd_above_left' l C (univ_mem_sets' hC)
id   └───────────────────────────────────┘    └────────────┘ └┘
src  └───────────────────────────────────┘      └────────────┘
typ  └───────────────────────────────────┘    └────────────┘ └┘
1752  
1753  lemma tendsto_at_top_of_add_bdd_above_right' (C) (hC : {x | g x ≤ C} ∈ l)
id                                                                   
src                                                                     
typ                                                                  
1754    (h : tendsto (λ x, f x + g x) l at_top) :
id          └─────┘             └────┘
src         └─────┘                   └────┘
typ         └─────┘             └────┘
doc         └─────┘                    └────┘
1755    tendsto f l at_top :=
id     └─────┘   └────┘
src    └─────┘     └────┘
typ    └─────┘   └────┘
doc    └─────┘     └────┘
1756  tendsto_at_top_of_add_const_right l C
id   └───────────────────────────────┘  
src  └───────────────────────────────┘
typ  └───────────────────────────────┘  
1757    (tendsto_at_top_mono' l (monotone_mem_sets (λ x (hx : g x ≤ C), add_le_add_left hx (f x)) hC) h)
id      └──────────────────┘   └───────────────┘                 └─────────────┘ └┘      └┘  
src     └──────────────────┘    └───────────────┘                     └─────────────┘
typ     └──────────────────┘   └───────────────┘                 └─────────────┘ └┘      └┘  
1758  
1759  lemma tendsto_at_top_of_add_bdd_above_right (C) (hC : ∀ x, g x ≤ C) :
id                                                                
src                                                                 
typ                                                               
1760    tendsto (λ x, f x + g x) l at_top → tendsto f l at_top :=
id     └─────┘             └────┘   └─────┘   └────┘
src    └─────┘                   └────┘   └─────┘     └────┘
typ    └─────┘             └────┘   └─────┘   └────┘
doc    └─────┘                    └────┘   └─────┘     └────┘
1761  tendsto_at_top_of_add_bdd_above_right' l C (univ_mem_sets' hC)
id   └────────────────────────────────────┘    └────────────┘ └┘
src  └────────────────────────────────────┘      └────────────┘
typ  └────────────────────────────────────┘    └────────────┘ └┘
1762  
1763  end ordered_monoid
1764  
1765  section ordered_group
1766  
1767  variables [ordered_comm_group β] (l : filter α) {f g : α → β}
id              └────────────────┘         └────┘
src             └────────────────┘         └────┘
typ             └────────────────┘         └────┘
1768  
1769  lemma tendsto_at_top_add_left_of_le' (C : β) (hf : {x | C ≤ f x} ∈ l) (hg : tendsto g l at_top) :
id                                                                      └─────┘   └────┘
src                                                                           └─────┘     └────┘
typ                                                                     └─────┘   └────┘
doc                                                                              └─────┘     └────┘
1770    tendsto (λ x, f x + g x) l at_top :=
id     └─────┘             └────┘
src    └─────┘                   └────┘
typ    └─────┘             └────┘
doc    └─────┘                    └────┘
1771  @tendsto_at_top_of_add_bdd_above_left' _ _ _ l (λ x, -(f x)) (λ x, f x + g x) (-C)
id    └───────────────────────────────────┘                              
src   └───────────────────────────────────┘                                       
typ   └───────────────────────────────────┘                              
1772    (by simp [hf]) (by simp [hg])
id               └┘             └┘
src        └────┘        └────┘  
typ        └────┘└┘      └────┘└┘
doc        └────┘        └────┘  
txt        └────┘        └────┘  
par        └────┘        └────┘  
pid                          
st        └────────┘     └────────┘
1773  
1774  lemma tendsto_at_top_add_left_of_le (C : β) (hf : ∀ x, C ≤ f x) (hg : tendsto g l at_top) :
id                                                                   └─────┘   └────┘
src                                                                       └─────┘     └────┘
typ                                                                  └─────┘   └────┘
doc                                                                        └─────┘     └────┘
1775    tendsto (λ x, f x + g x) l at_top :=
id     └─────┘             └────┘
src    └─────┘                   └────┘
typ    └─────┘             └────┘
doc    └─────┘                    └────┘
1776  tendsto_at_top_add_left_of_le' l C (univ_mem_sets' hf) hg
id   └────────────────────────────┘    └────────────┘ └┘  └┘
src  └────────────────────────────┘      └────────────┘
typ  └────────────────────────────┘    └────────────┘ └┘  └┘
1777  
1778  lemma tendsto_at_top_add_right_of_le' (C : β) (hf : tendsto f l at_top) (hg : {x | C ≤ g x} ∈ l) :
id                                                      └─────┘   └────┘                 
src                                                      └─────┘     └────┘                    
typ                                                     └─────┘   └────┘                 
doc                                                      └─────┘     └────┘
1779    tendsto (λ x, f x + g x) l at_top :=
id     └─────┘             └────┘
src    └─────┘                   └────┘
typ    └─────┘             └────┘
doc    └─────┘                    └────┘
1780  @tendsto_at_top_of_add_bdd_above_right' _ _ _ l (λ x, f x + g x) (λ x, -(g x)) (-C)
id    └────────────────────────────────────┘                              
src   └────────────────────────────────────┘                                       
typ   └────────────────────────────────────┘                              
1781    (by simp [hg]) (by simp [hf])
id               └┘             └┘
src        └────┘        └────┘  
typ        └────┘└┘      └────┘└┘
doc        └────┘        └────┘  
txt        └────┘        └────┘  
par        └────┘        └────┘  
pid                          
st        └────────┘     └────────┘
1782  
1783  lemma tendsto_at_top_add_right_of_le (C : β) (hf : tendsto f l at_top) (hg : ∀ x, C ≤ g x) :
id                                                     └─────┘   └────┘               
src                                                     └─────┘     └────┘               
typ                                                    └─────┘   └────┘               
doc                                                     └─────┘     └────┘
1784    tendsto (λ x, f x + g x) l at_top :=
id     └─────┘             └────┘
src    └─────┘                   └────┘
typ    └─────┘             └────┘
doc    └─────┘                    └────┘
1785  tendsto_at_top_add_right_of_le' l C hf (univ_mem_sets' hg)
id   └─────────────────────────────┘   └┘  └────────────┘ └┘
src  └─────────────────────────────┘         └────────────┘
typ  └─────────────────────────────┘   └┘  └────────────┘ └┘
1786  
1787  lemma tendsto_at_top_add_const_left (C : β) (hf : tendsto f l at_top) :
id                                                    └─────┘   └────┘
src                                                    └─────┘     └────┘
typ                                                   └─────┘   └────┘
doc                                                    └─────┘     └────┘
1788    tendsto (λ x, C + f x) l at_top :=
id     └─────┘            └────┘
src    └─────┘                 └────┘
typ    └─────┘            └────┘
doc    └─────┘                  └────┘
1789  tendsto_at_top_add_left_of_le' l C (univ_mem_sets' $ λ _, le_refl C) hf
id   └────────────────────────────┘    └────────────┘       └─────┘   └┘
src  └────────────────────────────┘      └────────────┘        └─────┘
typ  └────────────────────────────┘    └────────────┘       └─────┘   └┘
1790  
1791  lemma tendsto_at_top_add_const_right (C : β) (hf : tendsto f l at_top) :
id                                                     └─────┘   └────┘
src                                                     └─────┘     └────┘
typ                                                    └─────┘   └────┘
doc                                                     └─────┘     └────┘
1792    tendsto (λ x, f x + C) l at_top :=
id     └─────┘            └────┘
src    └─────┘                 └────┘
typ    └─────┘            └────┘
doc    └─────┘                  └────┘
1793  tendsto_at_top_add_right_of_le' l C hf (univ_mem_sets' $ λ _, le_refl C)
id   └─────────────────────────────┘   └┘  └────────────┘       └─────┘ 
src  └─────────────────────────────┘         └────────────┘        └─────┘
typ  └─────────────────────────────┘   └┘  └────────────┘       └─────┘ 
1794  
1795  end ordered_group
1796  
1797  lemma tendsto_at_top' [nonempty α] [semilattice_sup α] (f : α → β) (l : filter β) :
id                          └──────┘    └─────────────┘                  └────┘ 
src                         └──────┘     └─────────────┘                     └────┘
typ                         └──────┘    └─────────────┘                  └────┘ 
doc                                      └─────────────┘
1798    tendsto f at_top l ↔ (∀s ∈ l, ∃a, ∀b≥a, f b ∈ s) :=
id     └─────┘  └────┘                  
src    └─────┘   └────┘                         
typ    └─────┘  └────┘                  
doc    └─────┘   └────┘
1799  by simp only [tendsto_def, mem_at_top_sets]; refl
id                 └─────────┘  └─────────────┘
src     └─────────┘└─────────┘└┘└─────────────┘  └────
typ     └─────────┘└─────────┘└┘└─────────────┘  └────
doc     └─────────┘           └┘                 └────
txt     └─────────┘           └┘                 └────
par     └─────────┘           └┘                 └────
pid         └──┘└┘           └┘                     
st     └───────────────────────────────────────────────
1800  
src  
typ  
doc  
txt  
par  
pid  
st   
1801  theorem tendsto_at_top_principal [nonempty β] [semilattice_sup β] {f : β → α} {s : set α} :
id                                     └──────┘    └─────────────┘                  └─┘ 
src                                    └──────┘     └─────────────┘                     └─┘
typ                                    └──────┘    └─────────────┘                  └─┘ 
doc                                                 └─────────────┘
1802    tendsto f at_top (principal s) ↔ ∃N, ∀n≥N, f n ∈ s :=
id     └─────┘  └────┘  └───────┘            
src    └─────┘   └────┘  └───────┘                 
typ    └─────┘  └────┘  └───────┘            
doc    └─────┘   └────┘  └───────┘
1803  by rw [tendsto_iff_comap, comap_principal, le_principal_iff, mem_at_top_sets]; refl
id          └───────────────┘  └─────────────┘  └──────────────┘  └─────────────┘
src     └──┘└───────────────┘└┘└─────────────┘└┘└──────────────┘└┘└─────────────┘  └────
typ     └──┘└───────────────┘└┘└─────────────┘└┘└──────────────┘└┘└─────────────┘  └────
doc     └──┘                 └┘               └┘                └┘                 └────
txt     └──┘                 └┘               └┘                └┘                 └────
par     └──┘                 └┘               └┘                └┘                 └────
pid       └┘                 └┘               └┘                └┘                     
st     └────────────────────┘└───────────────┘└────────────────┘└───────────────┘└──────
1804  
src  
typ  
doc  
txt  
par  
pid  
st   
1805  /-- A function `f` grows to infinity independent of an order-preserving embedding `e`. -/
1806  lemma tendsto_at_top_embedding {α β γ : Type*} [preorder β] [preorder γ]
id                                                   └──────┘    └──────┘ 
src                                                  └──────┘     └──────┘
typ                                                  └──────┘    └──────┘ 
1807    {f : α → β} {e : β → γ} {l : filter α}
id                              └────┘ 
src                                 └────┘
typ                             └────┘ 
1808    (hm : ∀b₁ b₂, e b₁ ≤ e b₂ ↔ b₁ ≤ b₂) (hu : ∀c, ∃b, c ≤ e b) :
id            └┘ └┘   └┘   └┘  └┘  └┘               
src                                                    
typ           └┘ └┘   └┘   └┘  └┘  └┘               
1809    tendsto (e ∘ f) l at_top ↔ tendsto f l at_top :=
id     └─────┘       └────┘  └─────┘   └────┘
src    └─────┘          └────┘  └─────┘     └────┘
typ    └─────┘       └────┘  └─────┘   └────┘
doc    └─────┘           └────┘   └─────┘     └────┘
1810  begin
st   └─────
1811    rw [tendsto_at_top, tendsto_at_top],
id         └────────────┘  └────────────┘
src    └──┘└────────────┘└┘└────────────┘
typ    └──┘└────────────┘└┘└────────────┘
doc    └──┘              └┘              
txt    └──┘              └┘              
par    └──┘              └┘              
pid      └┘              └┘              
st   ───────────────────┘└──────────────┘└──
1812    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
1813    { assume hc b,
src      └─────────┘
typ      └─────────┘
doc      └─────────┘
txt      └─────────┘
par      └─────────┘
pid      └─────────┘
st   ───┘└─────────┘└─
1814      filter_upwards [hc (e b)] assume a, (hm b (f a)).1 },
id                       └┘                 └┘   
src      └──────────────┘     └─┘      └──┘       └───┘
typ      └──────────────┘└┘ └─┘      └──┘ └┘  └───┘
doc      └──────────────┘     └─┘      └──┘       └───┘
txt      └──────────────┘     └─┘      └──┘       └───┘
par      └──────────────┘     └─┘      └──┘       └───┘
pid                    └┘     └┘      └──┘       └┘└─┘
st   ──────────────────────────────────────────────────────┘└┘
1815    { assume hb c,
src      └─────────┘
typ      └─────────┘
doc      └─────────┘
txt      └─────────┘
par      └─────────┘
pid      └─────────┘
st   ──────────────┘└─
1816      rcases hu c with ⟨b, hc⟩,
id              └┘ 
src      └─────┘   └───────────┘
typ      └─────┘└┘└───────────┘
doc      └─────┘   └───────────┘
txt      └─────┘   └───────────┘
par      └─────┘   └───────────┘
pid               └───────────┘
st   ───────────────────────────┘└─
1817      filter_upwards [hb b] assume a ha, le_trans hc ((hm b (f a)).2 ha) }
id                       └┘                └──────┘ └┘   └┘   
src      └──────────────┘   └┘      └─────┘└──────┘          └───┘  └┘
typ      └──────────────┘└┘└┘      └─────┘└──────┘└┘  └┘  └───┘  └┘
doc      └──────────────┘   └┘      └─────┘                  └───┘  └┘
txt      └──────────────┘   └┘      └─────┘                  └───┘  └┘
par      └──────────────┘   └┘      └─────┘                  └───┘  └┘
pid                    └┘         └─────┘                  └───┘  
st   ──────────────────────────────────────────────────────────────────────┘└─
1818  end
st   ──┘
1819  
1820  lemma tendsto_at_top_at_top [nonempty α] [semilattice_sup α] [preorder β] (f : α → β) :
id                                └──────┘    └─────────────┘    └──────┘           
src                               └──────┘     └─────────────┘     └──────┘
typ                               └──────┘    └─────────────┘    └──────┘           
doc                                            └─────────────┘
1821    tendsto f at_top at_top ↔ ∀ b : β, ∃ i : α, ∀ a : α, i ≤ a → b ≤ f a :=
id     └─────┘  └────┘ └────┘                                
src    └─────┘   └────┘ └────┘                                    
typ    └─────┘  └────┘ └────┘                                
doc    └─────┘   └────┘ └────┘
1822  iff.trans tendsto_infi $ forall_congr $ assume b, tendsto_at_top_principal
id   └───────┘ └──────────┘   └──────────┘            └──────────────────────┘
src  └───────┘ └──────────┘   └──────────┘             └──────────────────────┘
typ  └───────┘ └──────────┘   └──────────┘            └──────────────────────┘
1823  
1824  lemma tendsto_at_top_at_bot [nonempty α] [decidable_linear_order α] [preorder β] (f : α → β) :
id                                └──────┘    └────────────────────┘    └──────┘           
src                               └──────┘     └────────────────────┘     └──────┘
typ                               └──────┘    └────────────────────┘    └──────┘           
1825    tendsto f at_top at_bot ↔ ∀ (b : β), ∃ (i : α), ∀ (a : α), i ≤ a → b ≥ f a :=
id     └─────┘  └────┘ └────┘                                      
src    └─────┘   └────┘ └────┘                                          
typ    └─────┘  └────┘ └────┘                                      
doc    └─────┘   └────┘ └────┘
1826  @tendsto_at_top_at_top α (order_dual β) _ _ _ f
id    └───────────────────┘   └────────┘         
src   └───────────────────┘    └────────┘
typ   └───────────────────┘   └────────┘         
doc                            └────────┘
1827  
1828  lemma tendsto_at_top_at_top_of_monotone [nonempty α] [semilattice_sup α] [preorder β]
id                                            └──────┘    └─────────────┘    └──────┘ 
src                                           └──────┘     └─────────────┘     └──────┘
typ                                           └──────┘    └─────────────┘    └──────┘ 
doc                                                        └─────────────┘
1829    {f : α → β} (hf : monotone f) :
id                     └──────┘ 
src                      └──────┘
typ                    └──────┘ 
doc                      └──────┘
1830    tendsto f at_top at_top ↔ ∀ b : β, ∃ a : α, b ≤ f a :=
id     └─────┘  └────┘ └────┘                   
src    └─────┘   └────┘ └────┘                    
typ    └─────┘  └────┘ └────┘                   
doc    └─────┘   └────┘ └────┘
1831  (tendsto_at_top_at_top f).trans $ forall_congr $ λ b, exists_congr $ λ a,
id    └───────────────────┘  └───┘    └──────────┘       └──────────┘     
src   └───────────────────┘   └───┘    └──────────┘        └──────────┘
typ   └───────────────────┘  └───┘    └──────────┘       └──────────┘     
1832    ⟨λ h, h a (le_refl a), λ h a' ha', le_trans h $ hf ha'⟩
id             └─────┘       └┘ └─┘  └──────┘    └┘ └─┘
src               └─────┘                 └──────┘
typ            └─────┘       └┘ └─┘  └──────┘    └┘ └─┘
1833  
1834  alias tendsto_at_top_at_top_of_monotone ← monotone.tendsto_at_top_at_top
1835  
1836  lemma tendsto_finset_range : tendsto finset.range at_top at_top :=
id                                └─────┘ └──────────┘ └────┘ └────┘
src                               └─────┘ └──────────┘ └────┘ └────┘
typ                               └─────┘ └──────────┘ └────┘ └────┘
doc                               └─────┘ └──────────┘ └────┘ └────┘
1837  finset.range_mono.tendsto_at_top_at_top.2 finset.exists_nat_subset_range
id   └───────────────┘└────────────────────┘  └────────────────────────────┘
src  └───────────────┘                        └────────────────────────────┘
typ  └───────────────┘└────────────────────┘  └────────────────────────────┘
doc                   └────────────────────┘
1838  
1839  lemma tendsto_finset_image_at_top_at_top {i : β → γ} {j : γ → β} (h : ∀x, j (i x) = x) :
id                                                                              
src                                                                                    
typ                                                                             
1840    tendsto (finset.image j) at_top at_top :=
id     └─────┘  └──────────┘   └────┘ └────┘
src    └─────┘  └──────────┘    └────┘ └────┘
typ    └─────┘  └──────────┘   └────┘ └────┘
doc    └─────┘  └──────────┘    └────┘ └────┘
1841  have j ∘ i = id, from funext h,
id            └┘       └────┘ 
src             └┘       └────┘
typ           └┘       └────┘ 
1842  (finset.image_mono j).tendsto_at_top_at_top.2 $ assume s,
id    └───────────────┘  └───────────────────┘            
src   └───────────────┘                         
typ   └───────────────┘  └───────────────────┘            
doc                       └───────────────────┘
1843    ⟨s.image i, by simp only [finset.image_image, this, finset.image_id, le_refl]⟩
id      └────┘                 └────────────────┘  └──┘  └─────────────┘  └─────┘
src      └────┘       └─────────┘└────────────────┘└┘    └┘└─────────────┘└┘└─────┘
typ     └────┘      └─────────┘└────────────────┘└┘└──┘└┘└─────────────┘└┘└─────┘
doc      └────┘       └─────────┘                  └┘    └┘               └┘       
txt                   └─────────┘                  └┘    └┘               └┘       
par                   └─────────┘                  └┘    └┘               └┘       
pid                       └──┘└┘                  └┘    └┘               └┘       
st                   └─────────────────────────────────────────────────────────────┘
1844  
1845  lemma prod_at_top_at_top_eq {β₁ β₂ : Type*} [inhabited β₁] [inhabited β₂] [semilattice_sup β₁]
id                                                └───────┘ └┘   └───────┘ └┘   └─────────────┘ └┘
src                                               └───────┘      └───────┘      └─────────────┘
typ                                               └───────┘ └┘   └───────┘ └┘   └─────────────┘ └┘
doc                                                                             └─────────────┘
1846    [semilattice_sup β₂] : filter.prod (@at_top β₁ _) (@at_top β₂ _) = @at_top (β₁ × β₂) _ :=
id      └─────────────┘ └┘    └─────────┘   └────┘ └┘      └────┘ └┘      └────┘  └┘  └┘
src     └─────────────┘       └─────────┘   └────┘         └────┘         └────┘     
typ     └─────────────┘ └┘    └─────────┘   └────┘ └┘      └────┘ └┘      └────┘  └┘  └┘
doc     └─────────────┘       └─────────┘   └────┘         └────┘          └────┘
1847  by simp [at_top, prod_infi_left (default β₁), prod_infi_right (default β₂), infi_prod];
id            └────┘  └────────────┘  └─────┘ └┘   └─────────────┘  └─────┘ └┘   └───────┘
src     └────┘└────┘└┘└────────────┘ └─────┘  └─┘└─────────────┘ └─────┘  └─┘└───────┘
typ     └────┘└────┘└┘└────────────┘ └─────┘└┘└─┘└─────────────┘ └─────┘└┘└─┘└───────┘
doc     └────┘└────┘└┘                        └─┘                         └─┘         
txt     └────┘      └┘                        └─┘                         └─┘         
par     └────┘      └┘                        └─┘                         └─┘         
pid               └┘                        └─┘                         └─┘         
st     └─────────────────────────────────────────────────────────────────────────────────────
1848      exact infi_comm
id             └───────┘
src      └────┘└───────┘
typ      └────┘└───────┘
doc      └────┘         
txt      └────┘         
par      └────┘         
pid                    
st   ────────────────────
1849  
src  
typ  
doc  
txt  
par  
pid  
st   
1850  lemma prod_map_at_top_eq {α₁ α₂ β₁ β₂ : Type*} [inhabited β₁] [inhabited β₂]
id                                                   └───────┘ └┘   └───────┘ └┘
src                                                  └───────┘      └───────┘
typ                                                  └───────┘ └┘   └───────┘ └┘
1851    [semilattice_sup β₁] [semilattice_sup β₂] (u₁ : β₁ → α₁) (u₂ : β₂ → α₂) :
id      └─────────────┘ └┘   └─────────────┘ └┘        └┘   └┘        └┘   └┘
src     └─────────────┘      └─────────────┘
typ     └─────────────┘ └┘   └─────────────┘ └┘        └┘   └┘        └┘   └┘
doc     └─────────────┘      └─────────────┘
1852    filter.prod (map u₁ at_top) (map u₂ at_top) = map (prod.map u₁ u₂) at_top :=
id     └─────────┘  └─┘ └┘ └────┘   └─┘ └┘ └────┘   └─┘  └──────┘ └┘ └┘  └────┘
src    └─────────┘  └─┘    └────┘   └─┘    └────┘   └─┘  └──────┘        └────┘
typ    └─────────┘  └─┘ └┘ └────┘   └─┘ └┘ └────┘   └─┘  └──────┘ └┘ └┘  └────┘
doc    └─────────┘  └─┘    └────┘   └─┘    └────┘    └─┘                  └────┘
1853  by rw [prod_map_map_eq, prod_at_top_at_top_eq, prod.map_def]
id          └─────────────┘  └───────────────────┘  └──────────┘
src     └──┘└─────────────┘└┘└───────────────────┘└┘└──────────┘└─
typ     └──┘└─────────────┘└┘└───────────────────┘└┘└──────────┘└─
doc     └──┘               └┘                     └┘            └─
txt     └──┘               └┘                     └┘            └─
par     └──┘               └┘                     └┘            └─
pid       └┘               └┘                     └┘            
st     └──────────────────┘└─────────────────────┘└────────────┘
1854  
src  
typ  
doc  
txt  
par  
pid  
st   
1855  /-- A function `f` maps upwards closed sets (at_top sets) to upwards closed sets when it is a
1856  Galois insertion. The Galois "insertion" and "connection" is weakened to only require it to be an
1857  insertion and a connetion above `b'`. -/
1858  lemma map_at_top_eq_of_gc [semilattice_sup α] [semilattice_sup β] {f : α → β} (g : β → α) (b' : β)(hf : monotone f) (gc : ∀a, ∀b≥b', f a ≤ b ↔ a ≤ g b) (hgi : ∀b≥b', b ≤ f (g b)) :
id                              └─────────────┘    └─────────────┘                                    └──────┘              └┘                     └┘       
src                             └─────────────┘     └─────────────┘                                          └──────┘                                                     
typ                             └─────────────┘    └─────────────┘                                    └──────┘              └┘                     └┘       
doc                             └─────────────┘     └─────────────┘                                          └──────┘
1859    map f at_top = at_top :=
id     └─┘  └────┘  └────┘
src    └─┘   └────┘  └────┘
typ    └─┘  └────┘  └────┘
doc    └─┘   └────┘   └────┘
1860  begin
st   └─────
1861    rw [@map_at_top_eq α _ ⟨g b'⟩],
id          └───────────┘      └┘
src    └──┘ └───────────┘ └─┘    └┘
typ    └──┘ └───────────┘└─┘ └┘└┘
doc    └──┘               └─┘    └┘
txt    └──┘               └─┘    └┘
par    └──┘               └─┘    └┘
pid      └┘               └─┘    └┘
st   ──────────────────────────────┘└──
1862    refine le_antisymm
id            └─────────┘
src    └─────┘└─────────┘
typ    └─────┘└─────────┘
doc    └─────┘           
txt    └─────┘           
par    └─────┘           
pid                     
st   ─────────────────────
1863      (le_infi $ assume b, infi_le_of_le (g (b ⊔ b')) $ principal_mono.2 $ image_subset_iff.2 _)
id                                                                          └──────────────┘
src  ───┘               └──┘                   └─┘               └─┘ └──────────────┘└─────
typ  ───┘               └──┘                  └─┘               └─┘ └──────────────┘└─────
doc  ───┘               └──┘                    └─┘               └─┘ └──────────────┘└─────
txt  ───┘               └──┘                    └─┘               └─┘                 └─────
par  ───┘               └──┘                    └─┘               └─┘                 └─────
pid  ───┘               └──┘                    └─┘               └─┘                 └─────
st   ───────────────────────────────────────────────────────────────────────────────────────────────
1864      (le_infi $ assume a, infi_le_of_le (f a ⊔ b') $ principal_mono.2 _),
id        └─────┘             └───────────┘       └┘    └────────────┘
src  ───┘ └─────┘       └──┘└───────────┘      └┘ └────────────┘└───┘
typ  ───┘ └─────┘       └──┘└───────────┘   └┘└┘ └────────────┘└───┘
doc  ───┘               └──┘                   └┘               └───┘
txt  ───┘               └──┘                   └┘               └───┘
par  ───┘               └──┘                   └┘               └───┘
pid  ───┘               └──┘                   └┘               └───┘
st   ──────────────────────────────────────────────────────────────────────┘└─
1865    { assume a ha, exact (le_trans le_sup_left $ le_trans (hgi _ le_sup_right) $ hf ha) },
id                                    └─────────┘   └──────┘  └─┘   └──────────┘    └┘ └┘
src      └─────────┘  └────┘         └─────────┘ └──────┘    └─┘└──────────┘└┘     └┘
typ      └─────────┘  └────┘         └─────────┘ └──────┘ └─┘└─┘└──────────┘└┘ └┘└┘└┘
doc      └─────────┘  └────┘                                 └─┘            └┘     └┘
txt      └─────────┘  └────┘                                 └─┘            └┘     └┘
par      └─────────┘  └────┘                                 └─┘            └┘     └┘
pid      └─────────┘                                        └─┘            └┘     
st   ───┘└─────────┘└─────────────────────────────────────────────────────────────────────┘└┘
1866    { assume b hb,
src      └─────────┘
typ      └─────────┘
doc      └─────────┘
txt      └─────────┘
par      └─────────┘
pid      └─────────┘
st   ──────────────┘└─
1867      have hb' : b' ≤ b := le_trans le_sup_right hb,
id                  └┘      └──────┘ └──────────┘ └┘
src      └─────────┘   └──┘└──────┘└──────────┘
typ      └─────────┘└┘└──┘└──────┘└──────────┘└┘
doc      └─────────┘    └──┘                    
txt      └─────────┘    └──┘                    
par      └─────────┘    └──┘                    
pid      └──────┘└─┘    └──┘                    
st   ────────────────────────────────────────────────┘└─
1868      exact ⟨g b, (gc _ _ hb').1 (le_trans le_sup_left hb),
id                                 └──────┘ └─────────┘ └┘
src      └────┘   └┘   └───┘   └──┘ └──────┘└─────────┘  └──
typ      └────┘ └┘   └───┘   └──┘ └──────┘└─────────┘└┘└──
doc      └────┘   └┘   └───┘   └──┘                      └──
txt      └────┘   └┘   └───┘   └──┘                      └──
par      └────┘   └┘   └───┘   └──┘                      └──
pid              └┘   └───┘   └──┘                      └──
st   ──────────────────────────────────────────────────────────
1869        le_antisymm ((gc _ _ hb').2 (le_refl _)) (hgi _ hb')⟩ }
id         └─────────┘   └┘             └─────┘      └─┘   └─┘
src  ─────┘└─────────┘    └───┘   └──┘ └─────┘└───┘    └─┘   └─┘
typ  ─────┘└─────────┘  └┘└───┘   └──┘ └─────┘└───┘ └─┘└─┘└─┘└─┘
doc  ─────┘               └───┘   └──┘        └───┘    └─┘   └─┘
txt  ─────┘               └───┘   └──┘        └───┘    └─┘   └─┘
par  ─────┘               └───┘   └──┘        └───┘    └─┘   └─┘
pid  ─────┘               └───┘   └──┘        └───┘    └─┘   └┘
st   ───────────────────────────────────────────────────────────┘└─
1870  end
st   ──┘
1871  
1872  lemma map_add_at_top_eq_nat (k : ℕ) : map (λa, a + k) at_top = at_top :=
id                                        └─┘         └────┘  └────┘
src                                       └─┘            └────┘  └────┘
typ                                       └─┘         └────┘  └────┘
doc                                        └─┘             └────┘   └────┘
1873  map_at_top_eq_of_gc (λa, a - k) k
id   └─────────────────┘         
src  └─────────────────┘        
typ  └─────────────────┘         
doc  └─────────────────┘
1874    (assume a b h, add_le_add_right h k)
id                 └──────────────┘  
src                   └──────────────┘
typ                └──────────────┘  
1875    (assume a b h, (nat.le_sub_right_iff_add_le h).symm)
id                  └─────────────────────────┘  └──┘
src                    └─────────────────────────┘   └──┘
typ                 └─────────────────────────┘  └──┘
1876    (assume a h, by rw [nat.sub_add_cancel h])
id                       └────────────────┘ 
src                    └──┘└────────────────┘ 
typ                  └──┘└────────────────┘
doc                    └──┘                   
txt                    └──┘                   
par                    └──┘                   
pid                      └┘                   
st                    └───────────────────────┘
1877  
1878  lemma map_sub_at_top_eq_nat (k : ℕ) : map (λa, a - k) at_top = at_top :=
id                                        └─┘         └────┘  └────┘
src                                       └─┘            └────┘  └────┘
typ                                       └─┘         └────┘  └────┘
doc                                        └─┘             └────┘   └────┘
1879  map_at_top_eq_of_gc (λa, a + k) 0
id   └─────────────────┘       
src  └─────────────────┘        
typ  └─────────────────┘       
doc  └─────────────────┘
1880    (assume a b h, nat.sub_le_sub_right h _)
id                 └──────────────────┘ 
src                   └──────────────────┘
typ                └──────────────────┘ 
1881    (assume a b _, nat.sub_le_right_iff_le_add)
id                 └─────────────────────────┘
src                   └─────────────────────────┘
typ                └─────────────────────────┘
1882    (assume b _, by rw [nat.add_sub_cancel])
id                       └────────────────┘
src                    └──┘└────────────────┘
typ                  └──┘└────────────────┘
doc                    └──┘                  
txt                    └──┘                  
par                    └──┘                  
pid                      └┘                  
st                    └─────────────────────┘
1883  
1884  lemma tendso_add_at_top_nat (k : ℕ) : tendsto (λa, a + k) at_top at_top :=
id                                        └─────┘         └────┘ └────┘
src                                       └─────┘            └────┘ └────┘
typ                                       └─────┘         └────┘ └────┘
doc                                        └─────┘             └────┘ └────┘
1885  le_of_eq (map_add_at_top_eq_nat k)
id   └──────┘  └───────────────────┘ 
src  └──────┘  └───────────────────┘
typ  └──────┘  └───────────────────┘ 
1886  
1887  lemma tendso_sub_at_top_nat (k : ℕ) : tendsto (λa, a - k) at_top at_top :=
id                                        └─────┘         └────┘ └────┘
src                                       └─────┘            └────┘ └────┘
typ                                       └─────┘         └────┘ └────┘
doc                                        └─────┘             └────┘ └────┘
1888  le_of_eq (map_sub_at_top_eq_nat k)
id   └──────┘  └───────────────────┘ 
src  └──────┘  └───────────────────┘
typ  └──────┘  └───────────────────┘ 
1889  
1890  lemma tendsto_add_at_top_iff_nat {f : ℕ → α} {l : filter α} (k : ℕ) :
id                                                   └────┘        
src                                                   └────┘         
typ                                                  └────┘        
1891    tendsto (λn, f (n + k)) at_top l ↔ tendsto f at_top l :=
id     └─────┘            └────┘   └─────┘  └────┘ 
src    └─────┘                └────┘    └─────┘   └────┘
typ    └─────┘            └────┘   └─────┘  └────┘ 
doc    └─────┘                 └────┘     └─────┘   └────┘
1892  show tendsto (f ∘ (λn, n + k)) at_top l ↔ tendsto f at_top l,
id        └─────┘             └────┘   └─────┘  └────┘ 
src       └─────┘                 └────┘    └─────┘   └────┘
typ       └─────┘             └────┘   └─────┘  └────┘ 
doc       └─────┘                   └────┘     └─────┘   └────┘
1893    by rw [← tendsto_map'_iff, map_add_at_top_eq_nat]
id              └──────────────┘  └───────────────────┘
src       └────┘└──────────────┘└┘└───────────────────┘└─
typ       └────┘└──────────────┘└┘└───────────────────┘└─
doc       └────┘                └┘                     └─
txt       └────┘                └┘                     └─
par       └────┘                └┘                     └─
pid         └──┘                └┘                     
st       └─────────────────────┘└─────────────────────┘
1894  
src  
typ  
doc  
txt  
par  
pid  
st   
1895  lemma map_div_at_top_eq_nat (k : ℕ) (hk : k > 0) : map (λa, a / k) at_top = at_top :=
id                                                   └─┘         └────┘  └────┘
src                                                   └─┘            └────┘  └────┘
typ                                                  └─┘         └────┘  └────┘
doc                                                     └─┘             └────┘   └────┘
1896  map_at_top_eq_of_gc (λb, b * k + (k - 1)) 1
id   └─────────────────┘           
src  └─────────────────┘               
typ  └─────────────────┘           
doc  └─────────────────┘
1897    (assume a b h, nat.div_le_div_right h)
id                 └──────────────────┘ 
src                   └──────────────────┘
typ                └──────────────────┘ 
1898    (assume a b _,
id               
typ              
1899      calc a / k ≤ b ↔ a / k < b + 1 : by rw [← nat.succ_eq_add_one, nat.lt_succ_iff]
id                                      └─────────────────┘  └─────────────┘
src                                     └────┘└─────────────────┘└┘└─────────────┘└─
typ                               └────┘└─────────────────┘└┘└─────────────┘└─
doc                                          └────┘                   └┘               └─
txt                                          └────┘                   └┘               └─
par                                          └────┘                   └┘               └─
pid                                            └──┘                   └┘               
st                                          └────────────────────────┘└───────────────┘
1900        ... ↔ a < (b + 1) * k : nat.div_lt_iff_lt_mul _ _ hk
id                           └───────────────────┘     └┘
src  ─────┘                     └───────────────────┘
typ  ─────┘                  └───────────────────┘     └┘
doc  ─────┘
txt  ─────┘
par  ─────┘
pid  ─────┘
st   ─────┘
1901        ... ↔ _ :
1902        begin
st         └─────
1903          cases k,
id                 
src          └────┘
typ          └────┘
doc          └────┘
txt          └────┘
par          └────┘
pid               
st   ──────────────┘└─
1904          exact (lt_irrefl _ hk).elim,
id                  └───────┘   └┘
src          └────┘ └───────┘└─┘  └────┘
typ          └────┘ └───────┘└─┘└┘└────┘
doc          └────┘          └─┘  └────┘
txt          └────┘          └─┘  └────┘
par          └────┘          └─┘  └────┘
pid                         └─┘  └───┘
st   ──────────────────────────────────┘└─
1905          simp [mul_add, add_mul, nat.succ_add, nat.lt_succ_iff]
id                 └─────┘  └─────┘  └──────────┘  └─────────────┘
src          └────┘└─────┘└┘└─────┘└┘└──────────┘└┘└─────────────┘└─
typ          └────┘└─────┘└┘└─────┘└┘└──────────┘└┘└─────────────┘└─
doc          └────┘       └┘       └┘            └┘               └─
txt          └────┘       └┘       └┘            └┘               └─
par          └────┘       └┘       └┘            └┘               └─
pid                     └┘       └┘            └┘               
st   ───────────────────────────────────────────────────────────────
1906        end)
src  ─────┘
typ  ─────┘
doc  ─────┘
txt  ─────┘
par  ─────┘
pid  ─────┘
st   ─────┘└─┘
1907    (assume b _,
id              
typ             
1908      calc b = (b * k) / k : by rw [nat.mul_div_cancel b hk]
id                               └────────────────┘  └┘
src                              └──┘└────────────────┘   └─
typ                          └──┘└────────────────┘└┘└─
doc                                └──┘                     └─
txt                                └──┘                     └─
par                                └──┘                     └─
pid                                  └┘                     
st                                └──────────────────────────┘
1909        ... ≤ (b * k + (k - 1)) / k : nat.div_le_div_right $ nat.le_add_right _ _)
id                               └──────────────────┘   └──────────────┘
src  ─────┘                          └──────────────────┘   └──────────────┘
typ  ─────┘                      └──────────────────┘   └──────────────┘
doc  ─────┘
txt  ─────┘
par  ─────┘
pid  ─────┘
st   ─────┘
1910  
1911  /- ultrafilter -/
1912  
1913  section ultrafilter
1914  open zorn
1915  
1916  variables {f g : filter α}
id                    └────┘
src                   └────┘
typ                   └────┘
1917  
1918  /-- An ultrafilter is a minimal (maximal in the set order) proper filter. -/
1919  def is_ultrafilter (f : filter α) := f ≠ ⊥ ∧ ∀g, g ≠ ⊥ → g ≤ f → f ≤ g
id                           └────┘                         
src                          └────┘                               
typ                          └────┘                         
1920  
1921  lemma ultrafilter_unique (hg : is_ultrafilter g) (hf : f ≠ ⊥) (h : f ≤ g) : f = g :=
id                                  └────────────┘                          
src                                 └────────────┘                              
typ                                 └────────────┘                          
doc                                 └────────────┘
1922  le_antisymm h (hg.right _ hf h)
id   └─────────┘   └┘└────┘   └┘ 
src  └─────────┘      └────┘
typ  └─────────┘   └┘└────┘   └┘ 
1923  
1924  lemma le_of_ultrafilter {g : filter α} (hf : is_ultrafilter f) (h : f ⊓ g ≠ ⊥) :
id                                └────┘         └────────────┘            
src                               └────┘          └────────────┘               
typ                               └────┘         └────────────┘            
doc                                               └────────────┘
1925    f ≤ g :=
id       
src      
typ      
1926  le_of_inf_eq $ ultrafilter_unique hf h inf_le_left
id   └──────────┘   └────────────────┘ └┘  └─────────┘
src  └──────────┘   └────────────────┘      └─────────┘
typ  └──────────┘   └────────────────┘ └┘  └─────────┘
1927  
1928  /-- Equivalent characterization of ultrafilters:
1929    A filter f is an ultrafilter if and only if for each set s,
1930    -s belongs to f if and only if s does not belong to f. -/
1931  lemma ultrafilter_iff_compl_mem_iff_not_mem :
1932    is_ultrafilter f ↔ (∀ s, -s ∈ f ↔ s ∉ f) :=
id     └────────────┘              
src    └────────────┘                  
typ    └────────────┘              
doc    └────────────┘
1933  ⟨assume hf s,
id           └┘ 
typ          └┘ 
1934     ⟨assume hns hs,
id              └─┘ └┘
typ             └─┘ └┘
1935        hf.1 $ empty_in_sets_eq_bot.mp $ by convert f.inter_sets hs hns; rw [inter_compl_self],
id         └┘    └──────────────────┘└─┘              └──────────┘ └┘ └─┘      └──────────────┘
src              └──────────────────┘└─┘      └──────┘└──────────┘       └──┘└──────────────┘
typ        └┘    └──────────────────┘└─┘      └──────┘└──────────┘└┘└─┘  └──┘└──────────────┘
doc                                            └──────┘                   └──┘                
txt                                            └──────┘                   └──┘                
par                                            └──────┘                   └──┘                
pid                                                                        └┘                
st                                            └────────────────────────────────┘└──────────────┘
1936      assume hs,
id              └┘
typ             └┘
1937        have f ≤ principal (-s), from
id                └───────┘  
src                └───────┘  
typ               └───────┘  
doc                 └───────┘
1938          le_of_ultrafilter hf $ assume h, hs $ mem_sets_of_eq_bot $
id           └───────────────┘ └┘            └┘   └────────────────┘
src          └───────────────┘                     └────────────────┘
typ          └───────────────┘ └┘            └┘   └────────────────┘
1939            by simp only [h, eq_self_iff_true, lattice.neg_neg],
id                             └──────────────┘  └─────────────┘
src               └─────────┘ └┘└──────────────┘└┘└─────────────┘
typ               └─────────┘└┘└──────────────┘└┘└─────────────┘
doc               └─────────┘ └┘                └┘               
txt               └─────────┘ └┘                └┘               
par               └─────────┘ └┘                └┘               
pid                   └──┘└┘ └┘                └┘               
st               └───────────────────────────────────────────────┘
1940        by simp only [le_principal_iff] at this; assumption⟩,
id                       └──────────────┘
src           └─────────┘└──────────────┘└───────┘  └────────┘
typ           └─────────┘└──────────────┘└───────┘  └────────┘
doc           └─────────┘                └───────┘  └────────┘
txt           └─────────┘                └───────┘  └────────┘
par           └─────────┘                └───────┘  └────────┘
pid               └──┘└┘                └─────┘
st           └───────────────────────────────────────────────┘
1941   assume hf,
id           └┘
typ          └┘
1942     ⟨mt empty_in_sets_eq_bot.mpr ((hf ∅).mp (by convert f.univ_sets; rw [compl_empty])),
id       └┘ └──────────────────┘└──┘   └┘  └┘              └─────────┘      └─────────┘
src      └┘ └──────────────────┘└──┘       └┘      └──────┘└─────────┘  └──┘└─────────┘
typ      └┘ └──────────────────┘└──┘   └┘  └┘      └──────┘└─────────┘  └──┘└─────────┘
doc                                                 └──────┘             └──┘           
txt                                                 └──────┘             └──┘           
par                                                 └──────┘             └──┘           
pid                                                                       └┘           
st                                                 └────────────────────────┘└─────────┘
1943      assume g hg g_le s hs, classical.by_contradiction $ mt (hf s).mpr $
id               └┘ └──┘  └┘  └────────────────────────┘   └┘  └┘  └─┘
src                             └────────────────────────┘   └┘       └─┘
typ              └┘ └──┘  └┘  └────────────────────────┘   └┘  └┘  └─┘
1944        assume : - s ∈ f,
id                     
src                    
typ                    
1945          have s ∩ -s ∈ g, from inter_mem_sets hs (g_le this),
id                           └────────────┘ └┘  └──┘ └──┘
src                             └────────────┘
typ                          └────────────┘ └┘  └──┘ └──┘
1946          by simp only [empty_in_sets_eq_bot, hg, inter_compl_self] at this; contradiction⟩⟩
id                         └──────────────────┘  └┘  └──────────────┘
src             └─────────┘└──────────────────┘└┘  └┘└──────────────┘└───────┘  └───────────┘
typ             └─────────┘└──────────────────┘└┘└┘└┘└──────────────┘└───────┘  └───────────┘
doc             └─────────┘                    └┘  └┘                └───────┘  └───────────┘
txt             └─────────┘                    └┘  └┘                └───────┘  └───────────┘
par             └─────────┘                    └┘  └┘                └───────┘  └───────────┘
pid                 └──┘└┘                    └┘  └┘                └─────┘
st             └────────────────────────────────────────────────────────────────────────────┘
1947  
1948  lemma mem_or_compl_mem_of_ultrafilter (hf : is_ultrafilter f) (s : set α) :
id                                               └────────────┘        └─┘ 
src                                              └────────────┘         └─┘
typ                                              └────────────┘        └─┘ 
doc                                              └────────────┘
1949    s ∈ f ∨ - s ∈ f :=
id            
src             
typ           
1950  classical.or_iff_not_imp_left.2 (ultrafilter_iff_compl_mem_iff_not_mem.mp hf s).mpr
id   └───────────────────────────┘   └───────────────────────────────────┘└─┘ └┘  └─┘
src  └───────────────────────────┘   └───────────────────────────────────┘└─┘      └─┘
typ  └───────────────────────────┘   └───────────────────────────────────┘└─┘ └┘  └─┘
doc                                   └───────────────────────────────────┘
1951  
1952  lemma mem_or_mem_of_ultrafilter {s t : set α} (hf : is_ultrafilter f) (h : s ∪ t ∈ f) :
id                                          └─┘         └────────────┘            
src                                         └─┘          └────────────┘              
typ                                         └─┘         └────────────┘            
doc                                                      └────────────┘
1953    s ∈ f ∨ t ∈ f :=
id           
src            
typ          
1954  (mem_or_compl_mem_of_ultrafilter hf s).imp_right
id    └─────────────────────────────┘ └┘  └───────┘
src   └─────────────────────────────┘      └───────┘
typ   └─────────────────────────────┘ └┘  └───────┘
1955    (assume : -s ∈ f, by filter_upwards [this, h] assume x hnx hx, hx.resolve_left hnx)
id                                                                  └───────────┘
src                       └──────────────┘    └┘ └┘      └─────────┘  └───────────┘
typ                     └──────────────┘    └┘ └┘      └─────────┘  └───────────┘
doc                         └──────────────┘    └┘ └┘      └─────────┘               
txt                         └──────────────┘    └┘ └┘      └─────────┘               
par                         └──────────────┘    └┘ └┘      └─────────┘               
pid                                       └┘    └┘       └─────────┘               
st                         └────────────────────────────────────────────────────────────┘
1956  
1957  lemma mem_of_finite_sUnion_ultrafilter {s : set (set α)} (hf : is_ultrafilter f) (hs : finite s)
id                                               └─┘  └─┘          └────────────┘         └────┘ 
src                                              └─┘  └─┘           └────────────┘          └────┘
typ                                              └─┘  └─┘          └────────────┘         └────┘ 
doc                                                                 └────────────┘          └────┘
1958    : ⋃₀ s ∈ f → ∃t∈s, t ∈ f :=
id       └┘          
src      └┘              
typ      └┘          
1959  finite.induction_on hs (by simp only [empty_in_sets_eq_bot, hf.left, mem_empty_eq, sUnion_empty,
id   └─────────────────┘ └┘                └──────────────────┘           └──────────┘  └──────────┘
src  └─────────────────┘        └─────────┘└──────────────────┘└┘       └┘└──────────┘└┘└──────────┘└─
typ  └─────────────────┘ └┘     └─────────┘└──────────────────┘└┘└─────┘└┘└──────────┘└┘└──────────┘└─
doc                             └─────────┘                    └┘       └┘            └┘            └─
txt                             └─────────┘                    └┘       └┘            └┘            └─
par                             └─────────┘                    └┘       └┘            └┘            └─
pid                                 └──┘└┘                    └┘       └┘            └┘            └─
st                             └──────────────────────────────────────────────────────────────────────
1960    forall_prop_of_false, exists_false, not_false_iff, exists_prop_of_false]) $
id     └──────────────────┘  └──────────┘  └───────────┘  └──────────────────┘
src  ─┘└──────────────────┘└┘└──────────┘└┘└───────────┘└┘└──────────────────┘
typ  ─┘└──────────────────┘└┘└──────────┘└┘└───────────┘└┘└──────────────────┘
doc  ─┘                    └┘            └┘             └┘                    
txt  ─┘                    └┘            └┘             └┘                    
par  ─┘                    └┘            └┘             └┘                    
pid  ─┘                    └┘            └┘             └┘                    
st   ─────────────────────────────────────────────────────────────────────────┘
1961  λ t s' ht' hs' ih, by simp only [exists_prop, mem_insert_iff, set.sUnion_insert]; exact
id      └┘ └─┘ └─┘ └┘                └─────────┘  └────────────┘  └───────────────┘
src                        └─────────┘└─────────┘└┘└────────────┘└┘└───────────────┘  └────┘
typ     └┘ └─┘ └─┘ └┘     └─────────┘└─────────┘└┘└────────────┘└┘└───────────────┘  └────┘
doc                        └─────────┘           └┘              └┘                   └────┘
txt                        └─────────┘           └┘              └┘                   └────┘
par                        └─────────┘           └┘              └┘                   └────┘
pid                            └──┘└┘           └┘              └┘                        
st                        └──────────────────────────────────────────────────────────────────
1962  assume h, (mem_or_mem_of_ultrafilter hf h).elim
id              └───────────────────────┘ └┘
src        └──┘ └───────────────────────┘   └──────
typ        └──┘ └───────────────────────┘└┘ └──────
doc        └──┘                             └──────
txt        └──┘                             └──────
par        └──┘                             └──────
pid        └──┘                             └──────
st   ────────────────────────────────────────────────
1963    (assume : t ∈ f, ⟨t, or.inl rfl, this⟩)
id                       └────┘ └─┘
src  ─┘       └─┘  └┘  └┘└────┘└─┘└┘    └──
typ  ─┘       └─┘ └┘ └┘└────┘└─┘└┘    └──
doc  ─┘       └─┘   └┘  └┘         └┘    └──
txt  ─┘       └─┘   └┘  └┘         └┘    └──
par  ─┘       └─┘   └┘  └┘         └┘    └──
pid  ─┘       └─┘   └┘  └┘         └┘    └──
st   ──────────────────────────────────────────
1964    (assume h, let ⟨t, hts', ht⟩ := ih h in ⟨t, or.inr hts', ht⟩)
id                       └──┘  └┘     └┘          └────┘
src  ─┘       └──┘     └┘    └┘  └───┘   └──┘  └┘└────┘    └┘  └──
typ  ─┘       └──┘    └┘└──┘└┘└┘└───┘└┘ └──┘  └┘└────┘    └┘  └──
doc  ─┘       └──┘     └┘    └┘  └───┘   └──┘  └┘          └┘  └──
txt  ─┘       └──┘     └┘    └┘  └───┘   └──┘  └┘          └┘  └──
par  ─┘       └──┘     └┘    └┘  └───┘   └──┘  └┘          └┘  └──
pid  ─┘       └──┘     └┘    └┘  └───┘   └──┘  └┘          └┘  └┘
st   ────────────────────────────────────────────────────────────────
1965  
src  
typ  
doc  
txt  
par  
pid  
st   
1966  lemma mem_of_finite_Union_ultrafilter {is : set β} {s : β → set α}
id                                               └─┘           └─┘ 
src                                              └─┘             └─┘
typ                                              └─┘           └─┘ 
1967    (hf : is_ultrafilter f) (his : finite is) (h : (⋃i∈is, s i) ∈ f) : ∃i∈is, s i ∈ f :=
id           └────────────┘          └────┘ └┘         └┘          └┘    
src          └────────────┘           └────┘                                    
typ          └────────────┘          └────┘ └┘         └┘          └┘    
doc          └────────────┘           └────┘               
1968  have his : finite (image s is), from finite_image s his,
id              └────┘  └───┘  └┘        └──────────┘  └─┘
src             └────┘  └───┘             └──────────┘
typ             └────┘  └───┘  └┘        └──────────┘  └─┘
doc             └────┘
1969  have h : (⋃₀ image s is) ∈ f, from by simp only [sUnion_image, set.sUnion_image]; assumption,
id             └┘ └───┘  └┘                        └──────────┘  └──────────────┘
src            └┘ └───┘                   └─────────┘└──────────┘└┘└──────────────┘  └────────┘
typ            └┘ └───┘  └┘             └─────────┘└──────────┘└┘└──────────────┘  └────────┘
doc                                        └─────────┘            └┘                  └────────┘
txt                                        └─────────┘            └┘                  └────────┘
par                                        └─────────┘            └┘                  └────────┘
pid                                            └──┘└┘            └┘                
st                                        └─────────────────────────────────────────────────────┘
1970  let ⟨t, ⟨i, hi, h_eq⟩, (ht : t ∈ f)⟩ := mem_of_finite_sUnion_ultrafilter hf his h in
id   └─┘        └┘  └──┘                 └──────────────────────────────┘ └┘ └─┘ 
src                                         └──────────────────────────────┘
typ  └─┘        └┘  └──┘                 └──────────────────────────────┘ └┘ └─┘ 
1971  ⟨i, hi, h_eq.symm ▸ ht⟩
id               └───┘ 
src              └───┘ 
typ              └───┘ 
1972  
1973  lemma ultrafilter_map {f : filter α} {m : α → β} (h : is_ultrafilter f) : is_ultrafilter (map m f) :=
id                              └────┘                  └────────────┘     └────────────┘  └─┘  
src                             └────┘                     └────────────┘      └────────────┘  └─┘
typ                             └────┘                  └────────────┘     └────────────┘  └─┘  
doc                                                        └────────────┘      └────────────┘  └─┘
1974  by rw ultrafilter_iff_compl_mem_iff_not_mem at ⊢ h; exact assume s, h (m ⁻¹' s)
id         └───────────────────────────────────┘                            └─┘
src     └─┘└───────────────────────────────────┘└─────┘  └────┘      └──┘   └─┘ └─
typ     └─┘└───────────────────────────────────┘└─────┘  └────┘      └──┘ └─┘ └─
doc     └─┘└───────────────────────────────────┘└─────┘  └────┘      └──┘   └─┘ └─
txt     └─┘                                     └─────┘  └────┘      └──┘       └─
par     └─┘                                     └─────┘  └────┘      └──┘       └─
pid                                            └─────┘             └──┘       
st     └─────────────────────────────────────────────────────────────────────────────
1975  
src  
typ  
doc  
txt  
par  
pid  
st   
1976  lemma ultrafilter_pure {a : α} : is_ultrafilter (pure a) :=
id                                   └────────────┘  └──┘ 
src                                   └────────────┘  └──┘
typ                                  └────────────┘  └──┘ 
doc                                   └────────────┘
1977  begin
st   └─────
1978    rw ultrafilter_iff_compl_mem_iff_not_mem, intro s,
id        └───────────────────────────────────┘
src    └─┘└───────────────────────────────────┘  └─────┘
typ    └─┘└───────────────────────────────────┘  └─────┘
doc    └─┘└───────────────────────────────────┘  └─────┘
txt    └─┘                                       └─────┘
par    └─┘                                       └─────┘
pid                                                  └┘
st   ─────────────────────────────────────────┘└───────┘└─
1979    rw [mem_pure_sets, mem_pure_sets], exact iff.rfl
id         └───────────┘  └───────────┘         └─────┘
src    └──┘└───────────┘└┘└───────────┘  └────┘└─────┘
typ    └──┘└───────────┘└┘└───────────┘  └────┘└─────┘
doc    └──┘             └┘               └────┘       
txt    └──┘             └┘               └────┘       
par    └──┘             └┘               └────┘       
pid      └┘             └┘                           
st   ──────────────────┘└─────────────┘└───────────────┘
1980  end
st   └─┘
1981  
1982  lemma ultrafilter_bind {f : filter α} (hf : is_ultrafilter f) {m : α → filter β}
id                               └────┘         └────────────┘           └────┘ 
src                              └────┘          └────────────┘             └────┘
typ                              └────┘         └────────────┘           └────┘ 
doc                                              └────────────┘
1983    (hm : ∀ a, is_ultrafilter (m a)) : is_ultrafilter (f.bind m) :=
id               └────────────┘        └────────────┘  └───┘ 
src               └────────────┘          └────────────┘   └───┘
typ              └────────────┘        └────────────┘  └───┘ 
doc               └────────────┘          └────────────┘   └───┘
1984  begin
st   └─────
1985    simp only [ultrafilter_iff_compl_mem_iff_not_mem] at ⊢ hf hm, intro s,
id                └───────────────────────────────────┘
src    └─────────┘└───────────────────────────────────┘└──────────┘  └─────┘
typ    └─────────┘└───────────────────────────────────┘└──────────┘  └─────┘
doc    └─────────┘└───────────────────────────────────┘└──────────┘  └─────┘
txt    └─────────┘                                     └──────────┘  └─────┘
par    └─────────┘                                     └──────────┘  └─────┘
pid        └──┘└┘                                     └────────┘       └┘
st   ─────────────────────────────────────────────────────────────┘└───────┘└─
1986    dsimp [bind, join, map, preimage],
id            └──┘  └──┘  └─┘  └──────┘
src    └─────┘└──┘└┘└──┘└┘└─┘└┘└──────┘
typ    └─────┘└──┘└┘└──┘└┘└─┘└┘└──────┘
doc    └─────┘└──┘└┘└──┘└┘└─┘└┘└──────┘
txt    └─────┘    └┘    └┘   └┘        
par    └─────┘    └┘    └┘   └┘        
pid             └┘    └┘   └┘        
st   ──────────────────────────────────┘└─
1987    simp only [hm], apply hf
id                └┘
src    └─────────┘    └────┘  
typ    └─────────┘└┘  └────┘  
doc    └─────────┘    └────┘  
txt    └─────────┘    └────┘  
par    └─────────┘    └────┘  
pid        └──┘└┘           
st   ───────────────┘└─────────┘
1988  end
st   └─┘
1989  
1990  /-- The ultrafilter lemma: Any proper filter is contained in an ultrafilter. -/
1991  lemma exists_ultrafilter (h : f ≠ ⊥) : ∃u, u ≤ f ∧ is_ultrafilter u :=
id                                            └────────────┘ 
src                                               └────────────┘
typ                                           └────────────┘ 
doc                                                     └────────────┘
1992  let
id   └─┘
typ  └─┘
1993    τ                := {f' // f' ≠ ⊥ ∧ f' ≤ f},
id                        └┘    └┘    └┘  
src                                       
typ                       └┘    └┘    └┘  
1994    r : τ → τ → Prop := λt₁ t₂, t₂.val ≤ t₁.val,
id                       └┘ └┘  └┘└──┘  └┘└──┘
src                                  └──┘    └──┘
typ                      └┘ └┘  └┘└──┘  └┘└──┘
1995    ⟨a, ha⟩          := nonempty_of_mem_sets h univ_mem_sets,
id                        └──────────────────┘  └───────────┘
src                        └──────────────────┘   └───────────┘
typ                       └──────────────────┘  └───────────┘
1996    top : τ          := ⟨f, h, le_refl f⟩,
id                             └─────┘ 
src                               └─────┘
typ                            └─────┘ 
1997    sup : Π(c:set τ), chain r c → τ :=
id              └─┘    └───┘     
src              └─┘     └───┘
typ             └─┘    └───┘     
doc                      └───┘
1998      λc hc, ⟨⨅a:{a:τ // a ∈ insert top c}, a.val.val,
id         └┘             └────┘ └─┘   └──────┘
src                          └────┘         └──────┘
typ        └┘             └────┘ └─┘   └──┘└──┘
doc                                         
1999        infi_ne_bot_of_directed ⟨a⟩
id         └─────────────────────┘
src        └─────────────────────┘
typ        └─────────────────────┘
doc        └─────────────────────┘
2000          (directed_of_chain $ chain_insert hc $ assume ⟨b, _, hb⟩ _ _, or.inl hb)
id            └───────────────┘   └──────────┘ └┘                └┘     └────┘
src           └───────────────┘   └──────────┘                             └────┘
typ           └───────────────┘   └──────────┘ └┘                └┘     └────┘
2001          (assume ⟨⟨a, ha, _⟩, _⟩, ha),
id                       └┘
typ                      └┘
2002        infi_le_of_le ⟨top, mem_insert _ _⟩ (le_refl _)⟩
id         └───────────┘  └─┘  └────────┘       └─────┘
src        └───────────┘       └────────┘       └─────┘
typ        └───────────┘  └─┘  └────────┘       └─────┘
2003  in
2004  have ∀c (hc: chain r c) a (ha : a ∈ c), r a (sup c hc),
id               └───┘                   └─┘  └┘
src               └───┘                
typ              └───┘                   └─┘  └┘
doc               └───┘
2005    from assume c hc a ha, infi_le_of_le ⟨a, mem_insert_of_mem _ ha⟩ (le_refl _),
id                  └┘  └┘  └───────────┘    └───────────────┘   └┘   └─────┘
src                           └───────────┘     └───────────────┘        └─────┘
typ                 └┘  └┘  └───────────┘    └───────────────┘   └┘   └─────┘
2006  have (∃ (u : τ), ∀ (a : τ), r u a → r a u),
id                                  
src                
typ                                 
2007    from exists_maximal_of_chains_bounded (assume c hc, ⟨sup c hc, this c hc⟩) (assume f₁ f₂ f₃ h₁ h₂, le_trans h₂ h₁),
id          └──────────────────────────────┘          └┘   └─┘  └┘  └──┘  └┘           └┘ └┘ └┘ └┘ └┘  └──────┘ └┘ └┘
src         └──────────────────────────────┘                                                              └──────┘
typ         └──────────────────────────────┘          └┘   └─┘  └┘  └──┘  └┘           └┘ └┘ └┘ └┘ └┘  └──────┘ └┘ └┘
doc         └──────────────────────────────┘
2008  let ⟨uτ, hmin⟩ := this in
id   └─┘  └┘  └──┘     └──┘
typ  └─┘  └┘  └──┘     └──┘
2009  ⟨uτ.val, uτ.property.right, uτ.property.left, assume g hg₁ hg₂,
id      └──┘    └───────┘└────┘    └───────┘└───┘          └─┘ └─┘
src     └──┘    └───────┘└────┘    └───────┘└───┘
typ     └──┘    └───────┘└────┘    └───────┘└───┘          └─┘ └─┘
2010    hmin ⟨g, hg₁, le_trans hg₂ uτ.property.right⟩ hg₂⟩
id             └─┘  └──────┘ └─┘   └───────┘└────┘  └─┘
src                  └──────┘       └───────┘└────┘
typ            └─┘  └──────┘ └─┘   └───────┘└────┘  └─┘
2011  
2012  /-- Construct an ultrafilter extending a given filter.
2013    The ultrafilter lemma is the assertion that such a filter exists;
2014    we use the axiom of choice to pick one. -/
2015  noncomputable def ultrafilter_of (f : filter α) : filter α :=
id                                         └────┘     └────┘ 
src                                        └────┘      └────┘
typ                                        └────┘     └────┘ 
2016  if h : f = ⊥ then ⊥ else classical.epsilon (λu, u ≤ f ∧ is_ultrafilter u)
id   └┘                   └───────────────┘         └────────────┘ 
src  └┘                    └───────────────┘            └────────────┘
typ  └┘                   └───────────────┘         └────────────┘ 
doc                                                          └────────────┘
2017  
2018  lemma ultrafilter_of_spec (h : f ≠ ⊥) : ultrafilter_of f ≤ f ∧ is_ultrafilter (ultrafilter_of f) :=
id                                        └────────────┘     └────────────┘  └────────────┘ 
src                                        └────────────┘       └────────────┘  └────────────┘
typ                                       └────────────┘     └────────────┘  └────────────┘ 
doc                                          └────────────┘         └────────────┘  └────────────┘
2019  begin
st   └─────
2020    have h' := classical.epsilon_spec (exists_ultrafilter h),
id                └────────────────────┘  └────────────────┘ 
src    └─────────┘└────────────────────┘ └────────────────┘ 
typ    └─────────┘└────────────────────┘ └────────────────┘
doc    └─────────┘                       └────────────────┘ 
txt    └─────────┘                                          
par    └─────────┘                                          
pid    └─────┘└─┘                                          
st   ─────────────────────────────────────────────────────────┘└─
2021    simp only [ultrafilter_of, dif_neg, h, dif_neg, not_false_iff],
id                └────────────┘  └─────┘    └─────┘  └───────────┘
src    └─────────┘└────────────┘└┘└─────┘└┘ └┘└─────┘└┘└───────────┘
typ    └─────────┘└────────────┘└┘└─────┘└┘└┘└─────┘└┘└───────────┘
doc    └─────────┘└────────────┘└┘       └┘ └┘       └┘             
txt    └─────────┘              └┘       └┘ └┘       └┘             
par    └─────────┘              └┘       └┘ └┘       └┘             
pid        └──┘└┘              └┘       └┘ └┘       └┘             
st   ───────────────────────────────────────────────────────────────┘└─
2022    simp only at h',
src    └─────────────┘
typ    └─────────────┘
doc    └─────────────┘
txt    └─────────────┘
par    └─────────────┘
pid        └──┘└───┘
st   ────────────────┘└─
2023    assumption
src    └─────────┘
typ    └─────────┘
doc    └─────────┘
txt    └─────────┘
par    └─────────┘
pid              
st   ────────────┘
2024  end
st   └─┘
2025  
2026  lemma ultrafilter_of_le : ultrafilter_of f ≤ f :=
id                             └────────────┘   
src                            └────────────┘   
typ                            └────────────┘   
doc                            └────────────┘
2027  if h : f = ⊥ then by simp only [ultrafilter_of, dif_pos, h, dif_pos, eq_self_iff_true, le_bot_iff]; exact le_refl _
id   └┘                           └────────────┘  └─────┘    └─────┘  └──────────────┘  └────────┘
src  └┘                 └─────────┘└────────────┘└┘└─────┘└┘ └┘└─────┘└┘└──────────────┘└┘└────────┘  └────┘       └──
typ  └┘                └─────────┘└────────────┘└┘└─────┘└┘└┘└─────┘└┘└──────────────┘└┘└────────┘  └────┘       └──
doc                       └─────────┘└────────────┘└┘       └┘ └┘       └┘                └┘            └────┘       └──
txt                       └─────────┘              └┘       └┘ └┘       └┘                └┘            └────┘       └──
par                       └─────────┘              └┘       └┘ └┘       └┘                └┘            └────┘       └──
pid                           └──┘└┘              └┘       └┘ └┘       └┘                └┘                        └┘
st                       └───────────────────────────────────────────────────────────────────────────────────────────────
2028    else (ultrafilter_of_spec h).left
id           └─────────────────┘  └──┘
src  ─┘      └─────────────────┘   └──┘
typ  ─┘      └─────────────────┘  └──┘
doc  ─┘
txt  ─┘
par  ─┘
pid  ─┘
st   ─┘
2029  
2030  lemma ultrafilter_ultrafilter_of (h : f ≠ ⊥) : is_ultrafilter (ultrafilter_of f) :=
id                                               └────────────┘  └────────────┘ 
src                                               └────────────┘  └────────────┘
typ                                              └────────────┘  └────────────┘ 
doc                                                 └────────────┘  └────────────┘
2031  (ultrafilter_of_spec h).right
id    └─────────────────┘  └───┘
src   └─────────────────┘   └───┘
typ   └─────────────────┘  └───┘
2032  
2033  lemma ultrafilter_of_ultrafilter (h : is_ultrafilter f) : ultrafilter_of f = f :=
id                                         └────────────┘     └────────────┘   
src                                        └────────────┘      └────────────┘   
typ                                        └────────────┘     └────────────┘   
doc                                        └────────────┘      └────────────┘
2034  ultrafilter_unique h (ultrafilter_ultrafilter_of h.left).left ultrafilter_of_le
id   └────────────────┘   └────────────────────────┘ └───┘ └──┘  └───────────────┘
src  └────────────────┘    └────────────────────────┘  └───┘ └──┘  └───────────────┘
typ  └────────────────┘   └────────────────────────┘ └───┘ └──┘  └───────────────┘
2035  
2036  /-- A filter equals the intersection of all the ultrafilters which contain it. -/
2037  lemma sup_of_ultrafilters (f : filter α) : f = ⨆ (g) (u : is_ultrafilter g) (H : g ≤ f), g :=
id                                  └────┘                └────────────┘            
src                                 └────┘                   └────────────┘              
typ                                 └────┘                └────────────┘            
doc                                                           └────────────┘               
2038  begin
st   └─────
2039    refine le_antisymm _ (supr_le $ λ g, supr_le $ λ u, supr_le $ λ H, H),
id            └─────────┘                                  └─────┘
src    └─────┘└─────────┘└─┘          └──┘         └──┘└─────┘  └──┘ 
typ    └─────┘└─────────┘└─┘          └──┘         └──┘└─────┘  └──┘ 
doc    └─────┘           └─┘          └──┘         └──┘         └──┘ 
txt    └─────┘           └─┘          └──┘         └──┘         └──┘ 
par    └─────┘           └─┘          └──┘         └──┘         └──┘ 
pid                     └─┘          └──┘         └──┘         └──┘ 
st   ──────────────────────────────────────────────────────────────────────┘└─
2040    intros s hs,
src    └─────────┘
typ    └─────────┘
doc    └─────────┘
txt    └─────────┘
par    └─────────┘
pid          └───┘
st   ────────────┘└─
2041    -- If s ∉ f.sets, we'll apply the ultrafilter lemma to the restriction of f to -s.
st   ─────────────────────────────────────────────────────────────────────────────────────
2042    by_contradiction hs',
src    └──────────────────┘
typ    └──────────────────┘
doc    └──────────────────┘
txt    └──────────────────┘
par    └──────────────────┘
pid                    └──┘
st   ─────────────────────┘└─
2043    let j : (-s) → α := subtype.val,
id                      └─────────┘
src    └──────┘  └┘  └──┘└─────────┘
typ    └──────┘ └┘ └──┘└─────────┘
doc    └──────┘   └┘  └──┘
txt    └──────┘   └┘  └──┘
par    └──────┘   └┘  └──┘
pid    └───┘└─┘   └┘  └──┘
st   ────────────────────────────────┘└─
2044    have j_inv_s : j ⁻¹' s = ∅, by
id                     └─┘   
src    └─────────────┘ └─┘ 
typ    └─────────────┘└─┘
doc    └─────────────┘ └─┘  
txt    └─────────────┘      
par    └─────────────┘      
pid    └──────────┘└─┘      
st   ───────────────────────────┘
2045      erw [←preimage_inter_range, subtype.val_range, inter_compl_self, preimage_empty],
id             └──────────────────┘  └───────────────┘  └──────────────┘  └────────────┘
src      └────┘└──────────────────┘└┘└───────────────┘└┘└──────────────┘└┘└────────────┘
typ      └────┘└──────────────────┘└┘└───────────────┘└┘└──────────────┘└┘└────────────┘
doc      └────┘                    └┘                 └┘                └┘              
txt      └────┘                    └┘                 └┘                └┘              
par      └────┘                    └┘                 └┘                └┘              
pid         └─┘                    └┘                 └┘                └┘              
st            └───────────────────┘└─────────────────┘└────────────────┘└──────────────┘└─
2046    let f' := comap j f,
id               └───┘  
src    └────────┘└───┘ 
typ    └────────┘└───┘
doc    └────────┘└───┘ 
txt    └────────┘      
par    └────────┘      
pid    └────┘└─┘      
st   ────────────────────┘└─
2047    have : f' ≠ ⊥,
id            └┘  
src    └─────┘  
typ    └─────┘└┘
doc    └─────┘   
txt    └─────┘   
par    └─────┘   
pid    └───┘└┘   
st   ──────────────┘└─
2048    { apply mt empty_in_sets_eq_bot.mpr,
id             └┘ └──────────────────────┘
src      └────┘└┘└──────────────────────┘
typ      └────┘└┘└──────────────────────┘
doc      └────┘  
txt      └────┘  
par      └────┘  
pid             
st   ───┘└───────────────────────────────┘└─
2049      rintro ⟨t, htf, ht⟩,
src      └─────────────────┘
typ      └─────────────────┘
doc      └─────────────────┘
txt      └─────────────────┘
par      └─────────────────┘
pid            └───────────┘
st   ──────────────────────┘└─
2050      suffices : t ⊆ s, from absurd (f.sets_of_superset htf this) hs',
id                           └────┘  └────────────────┘ └─┘ └──┘  └─┘
src      └─────────┘    └───┘└────┘ └────────────────┘       └┘
typ      └─────────┘  └───┘└────┘ └────────────────┘└─┘└──┘└┘└─┘
doc      └─────────┘     └───┘                                └┘
txt      └─────────┘     └───┘                                └┘
par      └─────────┘     └───┘                                └┘
pid      └───────┘└┘     └───┘                                └┘
st   ───────────────────┘└─────────────────────────────────────────────┘└─
2051      rw [subset_empty_iff] at ht,
id           └──────────────┘
src      └──┘└──────────────┘└─────┘
typ      └──┘└──────────────┘└─────┘
doc      └──┘                └─────┘
txt      └──┘                └─────┘
par      └──┘                └─────┘
pid        └┘                └────┘
st   ───────────────────────┘└────┘└─
2052      have : j '' (j ⁻¹' t) = ∅, by rw [ht, image_empty],
id                └┘                     └┘  └─────────┘
src      └─────┘ └┘      └┘       └──┘  └┘└─────────┘
typ      └─────┘ └┘    └┘       └──┘└┘└┘└─────────┘
doc      └─────┘         └┘       └──┘  └┘           
txt      └─────┘         └┘       └──┘  └┘           
par      └─────┘         └┘       └──┘  └┘           
pid      └───┘└┘         └┘         └┘  └┘           
st   ────────────────────────────┘         └┘└───────────┘└─
2053      erw [image_preimage_eq_inter_range, subtype.val_range, ←subset_compl_iff_disjoint,
id            └───────────────────────────┘  └───────────────┘   └───────────────────────┘
src      └───┘└───────────────────────────┘└┘└───────────────┘└─┘└───────────────────────┘└─
typ      └───┘└───────────────────────────┘└┘└───────────────┘└─┘└───────────────────────┘└─
doc      └───┘                             └┘                 └─┘                         └─
txt      └───┘                             └┘                 └─┘                         └─
par      └───┘                             └┘                 └─┘                         └─
pid         └┘                             └┘                 └─┘                         └─
st   ─────────────────────────────────────┘└─────────────────┘└──────────────────────────┘└─
2054        set.compl_compl] at this,
id         └─────────────┘
src  ─────┘└─────────────┘└───────┘
typ  ─────┘└─────────────┘└───────┘
doc  ─────┘               └───────┘
txt  ─────┘               └───────┘
par  ─────┘               └───────┘
pid  ─────┘               └──────┘
st   ────────────────────┘└──────┘└─
2055      exact this },
id             └──┘
src      └────┘    
typ      └────┘└──┘
doc      └────┘    
txt      └────┘    
par      └────┘    
pid               
st   ──────────────┘└┘
2056    rcases exists_ultrafilter this with ⟨g', g'f', u'⟩,
id            └────────────────┘ └──┘
src    └─────┘└────────────────┘    └──────────────────┘
typ    └─────┘└────────────────┘└──┘└──────────────────┘
doc    └─────┘└────────────────┘    └──────────────────┘
txt    └─────┘                      └──────────────────┘
par    └─────┘                      └──────────────────┘
pid                                └──────────────────┘
st   ───────────────────────────────────────────────────┘└─
2057    simp only [supr_sets_eq, mem_Inter] at hs,
id                └──────────┘  └───────┘
src    └─────────┘└──────────┘└┘└───────┘└─────┘
typ    └─────────┘└──────────┘└┘└───────┘└─────┘
doc    └─────────┘            └┘         └─────┘
txt    └─────────┘            └┘         └─────┘
par    └─────────┘            └┘         └─────┘
pid        └──┘└┘            └┘         └───┘
st   ──────────────────────────────────────────┘└─
2058    have := hs (g'.map subtype.val) (ultrafilter_map u') (map_le_iff_le_comap.mpr g'f'),
id             └┘  └────┘ └─────────┘   └─────────────┘ └┘   └─────────────────────┘ └──┘
src    └──────┘   └────┘└─────────┘└┘ └─────────────┘  └┘ └─────────────────────┘    
typ    └──────┘└┘ └────┘└─────────┘└┘ └─────────────┘└┘└┘ └─────────────────────┘└──┘
doc    └──────┘   └────┘           └┘                  └┘                            
txt    └──────┘                    └┘                  └┘                            
par    └──────┘                    └┘                  └┘                            
pid    └───┘└─┘                    └┘                  └┘                            
st   ────────────────────────────────────────────────────────────────────────────────────┘└─
2059    rw [←le_principal_iff, map_le_iff_le_comap, comap_principal, j_inv_s, principal_empty,
id          └──────────────┘  └─────────────────┘  └─────────────┘  └─────┘  └─────────────┘
src    └───┘└──────────────┘└┘└─────────────────┘└┘└─────────────┘└┘       └┘└─────────────┘└─
typ    └───┘└──────────────┘└┘└─────────────────┘└┘└─────────────┘└┘└─────┘└┘└─────────────┘└─
doc    └───┘                └┘                   └┘               └┘       └┘               └─
txt    └───┘                └┘                   └┘               └┘       └┘               └─
par    └───┘                └┘                   └┘               └┘       └┘               └─
pid      └─┘                └┘                   └┘               └┘       └┘               └─
st   ──────────────────────┘└───────────────────┘└───────────────┘└───────┘└───────────────┘└─
2060      le_bot_iff] at this,
id       └────────┘
src  ───┘└────────┘└───────┘
typ  ───┘└────────┘└───────┘
doc  ───┘          └───────┘
txt  ───┘          └───────┘
par  ───┘          └───────┘
pid  ───┘          └──────┘
st   ─────────────┘└──────┘└─
2061    exact absurd this u'.1
id           └────┘ └──┘ └┘
src    └────┘└────┘      └─┘
typ    └────┘└────┘└──┘└┘└─┘
doc    └────┘            └─┘
txt    └────┘            └─┘
par    └────┘            └─┘
pid                     └─┘
st   ────────────────────────┘
2062  end
st   └─┘
2063  
2064  /-- The `tendsto` relation can be checked on ultrafilters. -/
2065  lemma tendsto_iff_ultrafilter (f : α → β) (l₁ : filter α) (l₂ : filter β) :
id                                                 └────┘         └────┘ 
src                                                  └────┘          └────┘
typ                                                └────┘         └────┘ 
2066    tendsto f l₁ l₂ ↔ ∀ g, is_ultrafilter g → g ≤ l₁ → g.map f ≤ l₂ :=
id     └─────┘  └┘ └┘      └────────────┘      └┘   └──┘   └┘
src    └─────┘               └────────────┘              └──┘   
typ    └─────┘  └┘ └┘      └────────────┘      └┘   └──┘   └┘
doc    └─────┘                └────────────┘               └──┘
2067  ⟨assume h g u gx, le_trans (map_mono gx) h,
id              └┘  └──────┘  └──────┘ └┘  
src                    └──────┘  └──────┘
typ             └┘  └──────┘  └──────┘ └┘  
2068   assume h, by rw [sup_of_ultrafilters l₁]; simpa only [tendsto, map_supr, supr_le_iff]⟩
id                    └─────────────────┘ └┘               └─────┘  └──────┘  └─────────┘
src                └──┘└─────────────────┘    └──────────┘└─────┘└┘└──────┘└┘└─────────┘
typ               └──┘└─────────────────┘└┘  └──────────┘└─────┘└┘└──────┘└┘└─────────┘
doc                └──┘└─────────────────┘    └──────────┘└─────┘└┘        └┘           
txt                └──┘                       └──────────┘       └┘        └┘           
par                └──┘                       └──────────┘       └┘        └┘           
pid                  └┘                            └──┘└┘       └┘        └┘           
st                └─────────────────────────┘└───────────────────────────────────────────┘
2069  
2070  /-- The ultrafilter monad. The monad structure on ultrafilters is the
2071    restriction of the one on filters. -/
2072  def ultrafilter (α : Type u) : Type u := {f : filter α // is_ultrafilter f}
id                                                └────┘     └────────────┘ 
src                                               └────┘      └────────────┘
typ                                               └────┘     └────────────┘ 
doc                                                            └────────────┘
2073  
2074  def ultrafilter.map (m : α → β) (u : ultrafilter α) : ultrafilter β :=
id                                      └─────────┘     └─────────┘ 
src                                       └─────────┘      └─────────┘
typ                                     └─────────┘     └─────────┘ 
doc                                       └─────────┘      └─────────┘
2075  ⟨u.val.map m, ultrafilter_map u.property⟩
id    └──┘└──┘   └─────────────┘ └───────┘
src    └──┘└──┘    └─────────────┘  └───────┘
typ   └──┘└──┘   └─────────────┘ └───────┘
doc        └──┘
2076  
2077  def ultrafilter.pure (x : α) : ultrafilter α := ⟨pure x, ultrafilter_pure⟩
id                                 └─────────┘      └──┘   └──────────────┘
src                                 └─────────┘       └──┘    └──────────────┘
typ                                └─────────┘      └──┘   └──────────────┘
doc                                 └─────────┘
2078  
2079  def ultrafilter.bind (u : ultrafilter α) (m : α → ultrafilter β) : ultrafilter β :=
id                             └─────────┘           └─────────┘     └─────────┘ 
src                            └─────────┘             └─────────┘      └─────────┘
typ                            └─────────┘           └─────────┘     └─────────┘ 
doc                            └─────────┘             └─────────┘      └─────────┘
2080  ⟨u.val.bind (λ a, (m a).val), ultrafilter_bind u.property (λ a, (m a).property)⟩
id    └──┘└───┘         └─┘    └──────────────┘ └───────┘         └──────┘
src    └──┘└───┘            └─┘    └──────────────┘  └───────┘            └──────┘
typ   └──┘└───┘         └─┘    └──────────────┘ └───────┘         └──────┘
doc        └───┘
2081  
2082  instance ultrafilter.has_pure : has_pure ultrafilter := ⟨@ultrafilter.pure⟩
id                                   └──────┘ └─────────┘      └──────────────┘
src                                  └──────┘ └─────────┘      └──────────────┘
typ                                  └──────┘ └─────────┘      └──────────────┘
doc                                           └─────────┘
2083  instance ultrafilter.has_bind : has_bind ultrafilter := ⟨@ultrafilter.bind⟩
id                                   └──────┘ └─────────┘      └──────────────┘
src                                  └──────┘ └─────────┘      └──────────────┘
typ                                  └──────┘ └─────────┘      └──────────────┘
doc                                           └─────────┘
2084  instance ultrafilter.functor : functor ultrafilter := { map := @ultrafilter.map }
id                                  └─────┘ └─────────┘              └─────────────┘
src                                 └─────┘ └─────────┘              └─────────────┘
typ                                 └─────┘ └─────────┘              └─────────────┘
doc                                         └─────────┘
2085  instance ultrafilter.monad : monad ultrafilter := { map := @ultrafilter.map }
id                                └───┘ └─────────┘              └─────────────┘
src                               └───┘ └─────────┘              └─────────────┘
typ                               └───┘ └─────────┘              └─────────────┘
doc                                     └─────────┘
2086  
2087  instance ultrafilter.inhabited [inhabited α] : inhabited (ultrafilter α) := ⟨pure (default _)⟩
id                                   └───────┘     └───────┘  └─────────┘       └──┘  └─────┘
src                                  └───────┘      └───────┘  └─────────┘        └──┘  └─────┘
typ                                  └───────┘     └───────┘  └─────────┘       └──┘  └─────┘
doc                                                            └─────────┘
2088  
2089  noncomputable def hyperfilter : filter α := ultrafilter_of cofinite
id                                   └────┘     └────────────┘ └──────┘
src                                  └────┘      └────────────┘ └──────┘
typ                                  └────┘     └────────────┘ └──────┘
doc                                              └────────────┘ └──────┘
2090  
2091  lemma hyperfilter_le_cofinite : @hyperfilter α ≤ cofinite :=
id                                    └─────────┘   └──────┘
src                                   └─────────┘    └──────┘
typ                                   └─────────┘   └──────┘
doc                                                   └──────┘
2092  ultrafilter_of_le
id   └───────────────┘
src  └───────────────┘
typ  └───────────────┘
2093  
2094  lemma is_ultrafilter_hyperfilter [infinite α] : is_ultrafilter (@hyperfilter α) :=
id                                     └──────┘     └────────────┘   └─────────┘ 
src                                    └──────┘      └────────────┘   └─────────┘
typ                                    └──────┘     └────────────┘   └─────────┘ 
doc                                                  └────────────┘
2095  (ultrafilter_of_spec cofinite_ne_bot).2
id    └─────────────────┘ └─────────────┘ 
src   └─────────────────┘ └─────────────┘ 
typ   └─────────────────┘ └─────────────┘ 
2096  
2097  theorem nmem_hyperfilter_of_finite [infinite α] {s : set α} (hf : s.finite) :
id                                       └──────┘        └─┘         └─────┘
src                                      └──────┘         └─┘           └─────┘
typ                                      └──────┘        └─┘         └─────┘
doc                                                                     └─────┘
2098    s ∉ @hyperfilter α :=
id        └─────────┘ 
src        └─────────┘
typ       └─────────┘ 
2099  λ hy,
id     └┘
typ    └┘
2100  have hx : -s ∉ hyperfilter :=
id               └─────────┘
src               └─────────┘
typ              └─────────┘
2101    λ hs, (ultrafilter_iff_compl_mem_iff_not_mem.mp is_ultrafilter_hyperfilter s).mp hs hy,
id       └┘   └───────────────────────────────────┘└─┘ └────────────────────────┘  └┘  └┘ └┘
src           └───────────────────────────────────┘└─┘ └────────────────────────┘   └┘
typ      └┘   └───────────────────────────────────┘└─┘ └────────────────────────┘  └┘  └┘ └┘
doc           └───────────────────────────────────┘
2102  have ht : -s ∈ cofinite.sets := by show -s ∈ {s | _}; rwa [set.mem_set_of_eq, lattice.neg_neg],
id               └──────┘└───┘                           └───────────────┘  └─────────────┘
src               └──────┘└───┘       └───┘ └────┘  └───┘└───────────────┘└┘└─────────────┘
typ              └──────┘└───┘       └───┘└────┘  └───┘└───────────────┘└┘└─────────────┘
doc                 └──────┘            └───┘    └────┘  └───┘                 └┘               
txt                                     └───┘    └────┘  └───┘                 └┘               
par                                     └───┘    └────┘  └───┘                 └┘               
pid                                     └───┘    └────┘     └┘                 └┘               
st                                     └───────────────────────┘└───────────────┘└───────────────┘
2103  hx $ hyperfilter_le_cofinite ht
id   └┘   └─────────────────────┘ └┘
src       └─────────────────────┘
typ  └┘   └─────────────────────┘ └┘
2104  
2105  theorem compl_mem_hyperfilter_of_finite [infinite α] {s : set α} (hf : set.finite s) :
id                                            └──────┘        └─┘         └────────┘ 
src                                           └──────┘         └─┘          └────────┘
typ                                           └──────┘        └─┘         └────────┘ 
doc                                                                         └────────┘
2106    -s ∈ @hyperfilter α :=
id        └─────────┘ 
src        └─────────┘
typ       └─────────┘ 
2107  (ultrafilter_iff_compl_mem_iff_not_mem.mp is_ultrafilter_hyperfilter s).mpr $
id    └───────────────────────────────────┘└─┘ └────────────────────────┘  └─┘
src   └───────────────────────────────────┘└─┘ └────────────────────────┘   └─┘
typ   └───────────────────────────────────┘└─┘ └────────────────────────┘  └─┘
doc   └───────────────────────────────────┘
2108  nmem_hyperfilter_of_finite hf
id   └────────────────────────┘ └┘
src  └────────────────────────┘
typ  └────────────────────────┘ └┘
2109  
2110  theorem mem_hyperfilter_of_finite_compl [infinite α] {s : set α} (hf : set.finite (-s)) :
id                                            └──────┘        └─┘         └────────┘  
src                                           └──────┘         └─┘          └────────┘  
typ                                           └──────┘        └─┘         └────────┘  
doc                                                                         └────────┘
2111    s ∈ @hyperfilter α :=
id        └─────────┘ 
src        └─────────┘
typ       └─────────┘ 
2112  have h : _ := compl_mem_hyperfilter_of_finite hf,
id                 └─────────────────────────────┘ └┘
src                └─────────────────────────────┘
typ                └─────────────────────────────┘ └┘
2113  by rwa [lattice.neg_neg] at h
id           └─────────────┘
src     └───┘└─────────────┘└──────
typ     └───┘└─────────────┘└──────
doc     └───┘               └──────
txt     └───┘               └──────
par     └───┘               └──────
pid        └┘               └───┘
st     └───────────────────┘└─────
2114  
src  
typ  
doc  
txt  
par  
pid  
st   
2115  section
2116  
2117  local attribute [instance] filter.monad filter.is_lawful_monad
id                              └──────────┘ └────────────────────┘
src                             └──────────┘ └────────────────────┘
typ                             └──────────┘ └────────────────────┘
2118  
2119  instance ultrafilter.is_lawful_monad : is_lawful_monad ultrafilter :=
id                                          └─────────────┘ └─────────┘
src                                         └─────────────┘ └─────────┘
typ                                         └─────────────┘ └─────────┘
doc                                                         └─────────┘
2120  { id_map := assume α f, subtype.eq (id_map f.val),
id                        └────────┘  └────┘ └──┘
src                         └────────┘  └────┘  └──┘
typ                       └────────┘  └────┘ └──┘
2121    pure_bind := assume α β a f, subtype.eq (pure_bind a (subtype.val ∘ f)),
id                              └────────┘  └───────┘   └─────────┘  
src                                 └────────┘  └───────┘    └─────────┘ 
typ                             └────────┘  └───────┘   └─────────┘  
2122    bind_assoc := assume α β γ f m₁ m₂, subtype.eq (filter_eq rfl),
id                              └┘ └┘  └────────┘  └───────┘ └─┘
src                                        └────────┘  └───────┘ └─┘
typ                             └┘ └┘  └────────┘  └───────┘ └─┘
2123    bind_pure_comp_eq_map := assume α β f x, subtype.eq (bind_pure_comp_eq_map _ f x.val) }
id                                          └────────┘  └───────────────────┘    └──┘
src                                             └────────┘  └───────────────────┘      └──┘
typ                                         └────────┘  └───────────────────┘    └──┘
2124  
2125  end
2126  
2127  lemma ultrafilter.eq_iff_val_le_val {u v : ultrafilter α} : u = v ↔ u.val ≤ v.val :=
id                                              └─────────┘         └──┘  └──┘
src                                             └─────────┘             └──┘   └──┘
typ                                             └─────────┘         └──┘  └──┘
doc                                             └─────────┘
2128  ⟨assume h, by rw h; exact le_refl _,
id                           └─────┘
src                └─┘   └────┘└─────┘└┘
typ               └─┘  └────┘└─────┘└┘
doc                └─┘   └────┘       └┘
txt                └─┘   └────┘       └┘
par                └─┘   └────┘       └┘
pid                                 └┘
st                └────────────────────┘
2129   assume h, by rw subtype.ext; apply ultrafilter_unique v.property u.property.1 h⟩
id                   └─────────┘        └────────────────┘ └────────┘ └────────┘   
src                └─┘└─────────┘  └────┘└────────────────┘└────────┘└────────┘└─┘
typ               └─┘└─────────┘  └────┘└────────────────┘└────────┘└────────┘└─┘
doc                └─┘             └────┘                                      └─┘
txt                └─┘             └────┘                                      └─┘
par                └─┘             └────┘                                      └─┘
pid                                                                          └─┘
st                └─────────────────────────────────────────────────────────────────┘
2130  
2131  lemma exists_ultrafilter_iff (f : filter α) : (∃ (u : ultrafilter α), u.val ≤ f) ↔ f ≠ ⊥ :=
id                                     └────┘            └─────────┘   └──┘       
src                                    └────┘             └─────────┘     └──┘         
typ                                    └────┘            └─────────┘   └──┘       
doc                                                        └─────────┘
2132  ⟨assume ⟨u, uf⟩, lattice.ne_bot_of_le_ne_bot u.property.1 uf,
id             └┘   └─────────────────────────┘  └───────┘
src                   └─────────────────────────┘  └───────┘
typ            └┘   └─────────────────────────┘  └───────┘
2133   assume h, let ⟨u, uf, hu⟩ := exists_ultrafilter h in ⟨⟨u, hu⟩, uf⟩⟩
id             └─┘    └┘  └┘     └────────────────┘ 
src                                └────────────────┘
typ            └─┘    └┘  └┘     └────────────────┘ 
doc                                └────────────────┘
2134  
2135  end ultrafilter
2136  
2137  end filter
2138  
2139  namespace filter
2140  variables {α β γ : Type u} {f : β → filter α} {s : γ → set α}
id                                       └────┘             └─┘
src                                      └────┘             └─┘
typ                                      └────┘             └─┘
2141  open list
2142  
2143  lemma mem_traverse_sets :
2144    ∀(fs : list β) (us : list γ),
id           └──┘         └──┘ 
src           └──┘          └──┘
typ          └──┘         └──┘ 
2145      forall₂ (λb c, s c ∈ f b) fs us → traverse s us ∈ traverse f fs
id       └─────┘            └┘ └┘   └──────┘  └┘  └──────┘  └┘
src      └─────┘                          └──────┘       └──────┘
typ      └─────┘            └┘ └┘   └──────┘  └┘  └──────┘  └┘
2146  | []      []      forall₂.nil         := mem_pure_sets.2 $ mem_singleton _
id     └┘      └┘      └─────────┘            └───────────┘    └───────────┘
src    └┘      └┘      └─────────┘            └───────────┘    └───────────┘
typ    └┘      └┘      └─────────┘            └───────────┘    └───────────┘
2147  | (f::fs) (u::us) (forall₂.cons h hs) := seq_mem_seq_sets (image_mem_map h) (mem_traverse_sets fs us hs)
id       └┘└┘    └┘└┘   └──────────┘  └┘     └──────────────┘  └───────────┘     └───────────────┘
src      └┘      └┘     └──────────┘          └──────────────┘  └───────────┘
typ      └┘└┘    └┘└┘   └──────────┘  └┘     └──────────────┘  └───────────┘     └───────────────┘
2148  
2149  lemma mem_traverse_sets_iff (fs : list β) (t : set (list α)) :
id                                     └──┘        └─┘  └──┘ 
src                                    └──┘         └─┘  └──┘
typ                                    └──┘        └─┘  └──┘ 
2150    t ∈ traverse f fs ↔
id       └──────┘  └┘ 
src       └──────┘      
typ      └──────┘  └┘ 
2151      (∃us:list (set α), forall₂ (λb (s : set α), s ∈ f b) fs us ∧ sequence us ⊆ t) :=
id           └──┘  └─┘   └─────┘         └─┘         └┘ └┘  └──────┘ └┘  
src          └──┘  └─┘    └─────┘          └─┘                    └──────┘    
typ          └──┘  └─┘   └─────┘         └─┘         └┘ └┘  └──────┘ └┘  
2152  begin
st   └─────
2153    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
2154    { induction fs generalizing t,
id                 └┘
src      └────────┘  └─────────────┘
typ      └────────┘└┘└─────────────┘
doc      └────────┘  └─────────────┘
txt      └────────┘  └─────────────┘
par      └────────┘  └─────────────┘
pid                 └────────────┘
st   ───┘└─────────────────────────┘└─
2155      case nil { simp only [sequence, mem_pure_sets, imp_self, forall₂_nil_left_iff,
id                             └──────┘  └───────────┘  └──────┘  └──────────────────┘
src      └─────────┘└─────────┘└──────┘└┘└───────────┘└┘└──────┘└┘└──────────────────┘└─
typ      └─────────┘└─────────┘└──────┘└┘└───────────┘└┘└──────┘└┘└──────────────────┘└─
doc      └─────────┘└─────────┘        └┘             └┘        └┘                    └─
txt      └─────────┘└─────────┘        └┘             └┘        └┘                    └─
par      └─────────┘└─────────┘        └┘             └┘        └┘                    └─
pid          └──┘└───────────┘        └┘             └┘        └┘                    └─
st   ─────────────┘└────────────────────────────────────────────────────────────────────
2156        exists_eq_left, set.pure_def, singleton_subset_iff, traverse_nil] },
id         └────────────┘  └──────────┘  └──────────────────┘  └──────────┘
src  ─────┘└────────────┘└┘└──────────┘└┘└──────────────────┘└┘└──────────┘└┘
typ  ─────┘└────────────┘└┘└──────────┘└┘└──────────────────┘└┘└──────────┘└┘
doc  ─────┘              └┘            └┘                    └┘            └┘
txt  ─────┘              └┘            └┘                    └┘            └┘
par  ─────┘              └┘            └┘                    └┘            └┘
pid  ─────┘              └┘            └┘                    └┘            └─┘
st   ───────────────────────────────────────────────────────────────────────┘└┘
2157      case cons : b fs ih t {
src      └───────────────────────
typ      └───────────────────────
doc      └───────────────────────
txt      └───────────────────────
par      └───────────────────────
pid          └───┘└──────────┘└──
st   ──────────────────────────┘
2158        assume ht,
src  ─────┘└───────┘└─
typ  ─────┘└───────┘└─
doc  ─────┘└───────┘└─
txt  ─────┘└───────┘└─
par  ─────┘└───────┘└─
pid  ─────────────────
st   ──────────────┘└─
2159        rcases mem_seq_sets_iff.1 ht with ⟨u, hu, v, hv, ht⟩,
id                └──────────────┘   └┘
src  ─────┘└─────┘└──────────────┘└─┘  └──────────────────────┘└─
typ  ─────┘└─────┘└──────────────┘└─┘└┘└──────────────────────┘└─
doc  ─────┘└─────┘                └─┘  └──────────────────────┘└─
txt  ─────┘└─────┘                └─┘  └──────────────────────┘└─
par  ─────┘└─────┘                └─┘  └──────────────────────┘└─
pid  ────────────┘                └─┘  └─────────────────────────
st   ─────────────────────────────────────────────────────────┘└─
2160        rcases mem_map_sets_iff.1 hu with ⟨w, hw, hwu⟩,
id                └──────────────┘   └┘
src  ─────┘└─────┘└──────────────┘└─┘  └────────────────┘└─
typ  ─────┘└─────┘└──────────────┘└─┘└┘└────────────────┘└─
doc  ─────┘└─────┘                └─┘  └────────────────┘└─
txt  ─────┘└─────┘                └─┘  └────────────────┘└─
par  ─────┘└─────┘                └─┘  └────────────────┘└─
pid  ────────────┘                └─┘  └───────────────────
st   ───────────────────────────────────────────────────┘└─
2161        rcases ih v hv with ⟨us, hus, hu⟩,
id                └┘  └┘
src  ─────┘└─────┘     └─────────────────┘└─
typ  ─────┘└─────┘└┘└┘└─────────────────┘└─
doc  ─────┘└─────┘     └─────────────────┘└─
txt  ─────┘└─────┘     └─────────────────┘└─
par  ─────┘└─────┘     └─────────────────┘└─
pid  ────────────┘     └────────────────────
st   ──────────────────────────────────────┘└─
2162        exact ⟨w :: us, forall₂.cons hw hus, subset.trans (set.seq_mono hwu hu) ht⟩ } },
id                    └┘  └──────────┘ └┘ └─┘  └──────────┘  └──────────┘ └─┘ └┘  └┘
src  ─────┘└────┘      └┘└──────────┘     └┘└──────────┘ └──────────┘     └┘  └┘└┘
typ  ─────┘└────┘   └┘└┘└──────────┘└┘└─┘└┘└──────────┘ └──────────┘└─┘└┘└┘└┘└┘└┘
doc  ─────┘└────┘      └┘                 └┘                              └┘  └┘└┘
txt  ─────┘└────┘      └┘                 └┘                              └┘  └┘└┘
par  ─────┘└────┘      └┘                 └┘                              └┘  └┘└┘
pid  ───────────┘      └┘                 └┘                              └┘  └─┘
st   ─────────────────────────────────────────────────────────────────────────────────┘└┘
2163    { rintros ⟨us, hus, hs⟩,
src      └───────────────────┘
typ      └───────────────────┘
doc      └───────────────────┘
txt      └───────────────────┘
par      └───────────────────┘
pid             └────────────┘
st   ────────────────────────┘└─
2164      exact mem_sets_of_superset (mem_traverse_sets _ _ hus) hs }
id             └──────────────────┘  └───────────────┘     └─┘  └┘
src      └────┘└──────────────────┘ └───────────────┘└───┘   └┘  
typ      └────┘└──────────────────┘ └───────────────┘└───┘└─┘└┘└┘
doc      └────┘                                      └───┘   └┘  
txt      └────┘                                      └───┘   └┘  
par      └────┘                                      └───┘   └┘  
pid                                                 └───┘   └┘  
st   ─────────────────────────────────────────────────────────────┘└─
2165  end
st   ──┘
2166  
2167  lemma sequence_mono :
2168    ∀(as bs : list (filter α)), forall₂ (≤) as bs → sequence as ≤ sequence bs
id              └──┘  └────┘     └─────┘    └┘ └┘   └──────┘ └┘  └──────┘ └┘
src              └──┘  └────┘      └─────┘            └──────┘     └──────┘
typ             └──┘  └────┘     └─────┘    └┘ └┘   └──────┘ └┘  └──────┘ └┘
2169  | []      []      forall₂.nil         := le_refl _
id     └┘      └┘      └─────────┘            └─────┘
src    └┘      └┘      └─────────┘            └─────┘
typ    └┘      └┘      └─────────┘            └─────┘
2170  | (a::as) (b::bs) (forall₂.cons h hs) := seq_mono (map_mono h) (sequence_mono as bs hs)
id       └┘└┘    └┘└┘   └──────────┘  └┘     └──────┘  └──────┘     └───────────┘
src      └┘      └┘     └──────────┘          └──────┘  └──────┘
typ      └┘└┘    └┘└┘   └──────────┘  └┘     └──────┘  └──────┘     └───────────┘
2171  
2172  end filter
2173  
2174  open filter
2175  
2176  lemma set.infinite_iff_frequently_cofinite {α : Type u} {s : set α} :
id                                                                └─┘ 
src                                                               └─┘
typ                                                               └─┘ 
2177    set.infinite s ↔ (∃ᶠ x in cofinite, x ∈ s) :=
id     └──────────┘    └┘  └┘ └──────┘   
src    └──────────┘     └┘   └┘ └──────┘   
typ    └──────────┘    └┘  └┘ └──────┘   
doc    └──────────┘      └┘   └┘ └──────┘
2178  frequently_cofinite_iff_infinite.symm
id   └──────────────────────────────┘└───┘
src  └──────────────────────────────┘└───┘
typ  └──────────────────────────────┘└───┘
2179  
2180  /-- For natural numbers the filters `cofinite` and `at_top` coincide. -/
2181  lemma nat.cofinite_eq_at_top : @cofinite ℕ = at_top :=
id                                   └──────┘   └────┘
src                                  └──────┘   └────┘
typ                                  └──────┘   └────┘
doc                                  └──────┘     └────┘
2182  begin
st   └─────
2183    ext s,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
pid       └┘
st   ──────┘└─
2184    simp only [mem_cofinite, mem_at_top_sets],
id                └──────────┘  └─────────────┘
src    └─────────┘└──────────┘└┘└─────────────┘
typ    └─────────┘└──────────┘└┘└─────────────┘
doc    └─────────┘            └┘               
txt    └─────────┘            └┘               
par    └─────────┘            └┘               
pid        └──┘└┘            └┘               
st   ──────────────────────────────────────────┘└─
2185    split,
src    └───┘
typ    └───┘
doc    └───┘
txt    └───┘
par    └───┘
st   ──────┘└─
2186    { assume hs,
src      └───────┘
typ      └───────┘
doc      └───────┘
txt      └───────┘
par      └───────┘
pid      └───────┘
st   ───┘└───────┘└─
2187      use (hs.to_finset.sup id) + 1,
id            └──────────────┘ └┘  
src      └──┘ └──────────────┘└┘└┘└┘
typ      └──┘ └──────────────┘└┘└┘└┘
doc      └──┘ └──────────────┘  └┘ └┘
txt      └──┘                   └┘ └┘
par      └──┘                   └┘ └┘
pid                            └┘ 
st   ────────────────────────────────┘└─
2188      assume b hb,
src      └─────────┘
typ      └─────────┘
doc      └─────────┘
txt      └─────────┘
par      └─────────┘
pid      └─────────┘
st   ──────────────┘└─
2189      by_contradiction hbs,
src      └──────────────────┘
typ      └──────────────────┘
doc      └──────────────────┘
txt      └──────────────────┘
par      └──────────────────┘
pid                      └──┘
st   ───────────────────────┘└─
2190      have := hs.to_finset.subset_range_sup_succ (finite.mem_to_finset.2 hbs),
id               └────────────────────────────────┘  └──────────────────┘   └─┘
src      └──────┘└────────────────────────────────┘ └──────────────────┘└─┘   
typ      └──────┘└────────────────────────────────┘ └──────────────────┘└─┘└─┘
doc      └──────┘└────────────────────────────────┘                     └─┘   
txt      └──────┘                                                       └─┘   
par      └──────┘                                                       └─┘   
pid      └───┘└─┘                                                       └─┘   
st   ──────────────────────────────────────────────────────────────────────────┘└─
2191      exact not_lt_of_le hb (finset.mem_range.1 this) },
id             └──────────┘ └┘  └──────────────┘   └──┘
src      └────┘└──────────┘   └──────────────┘└─┘    └┘
typ      └────┘└──────────┘└┘ └──────────────┘└─┘└──┘└┘
doc      └────┘                               └─┘    └┘
txt      └────┘                               └─┘    └┘
par      └────┘                               └─┘    └┘
pid                                          └─┘    
st   ───────────────────────────────────────────────────┘└┘
2192    { rintros ⟨N, hN⟩,
src      └─────────────┘
typ      └─────────────┘
doc      └─────────────┘
txt      └─────────────┘
par      └─────────────┘
pid             └──────┘
st   ──────────────────┘└─
2193      apply finite_subset (finite_lt_nat N),
id             └───────────┘  └───────────┘ 
src      └────┘└───────────┘ └───────────┘ 
typ      └────┘└───────────┘ └───────────┘
doc      └────┘                            
txt      └────┘                            
par      └────┘                            
pid                                       
st   ────────────────────────────────────────┘└─
2194      assume n hn,
src      └─────────┘
typ      └─────────┘
doc      └─────────┘
txt      └─────────┘
par      └─────────┘
pid      └─────────┘
st   ──────────────┘└─
2195      change n < N,
id                
src      └─────┘ 
typ      └─────┘
doc      └─────┘  
txt      └─────┘  
par      └─────┘  
pid              
st   ───────────────┘└─
2196      exact lt_of_not_ge (λ hn', hn $ hN n hn') }
id             └──────────┘         └┘   └┘ 
src      └────┘└──────────┘  └────┘         └┘
typ      └────┘└──────────┘  └────┘└┘ └┘   └┘
doc      └────┘              └────┘         └┘
txt      └────┘              └────┘         └┘
par      └────┘              └────┘         └┘
pid                         └────┘         
st   ─────────────────────────────────────────────┘└─
2197  end
st   ──┘